Skip to content

Commit 7b2f38b

Browse files
committed
step
1 parent b182b4d commit 7b2f38b

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3226,42 +3226,6 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
32263226
MaybeSimplifyHint(OBU.Inputs[0]);
32273227
MaybeSimplifyHint(OBU.Inputs[1]);
32283228
}
3229-
3230-
if (OBU.getTagName() == "align" && OBU.Inputs.size() == 2) {
3231-
RetainedKnowledge RK = getKnowledgeFromBundle(
3232-
*cast<AssumeInst>(II), II->bundle_op_info_begin()[Idx]);
3233-
if (!RK || RK.AttrKind != Attribute::Alignment ||
3234-
!isPowerOf2_64(RK.ArgValue))
3235-
continue;
3236-
SetVector<const Instruction *> WorkList;
3237-
bool AlignNeeded = false;
3238-
WorkList.insert(II);
3239-
for (unsigned I = 0; I != WorkList.size(); ++I) {
3240-
if (auto *LI = dyn_cast<LoadInst>(WorkList[I])) {
3241-
if (auto *AlignMD = LI->getMetadata(LLVMContext::MD_align)) {
3242-
auto *A = mdconst::extract<ConstantInt>(AlignMD->getOperand(0));
3243-
3244-
if (A->getZExtValue() % RK.ArgValue != 0) {
3245-
AlignNeeded = true;
3246-
break;
3247-
}
3248-
}
3249-
}
3250-
if (isa<ICmpInst>(WorkList[I])) {
3251-
AlignNeeded = true;
3252-
break;
3253-
}
3254-
if (WorkList.size() > 16) {
3255-
AlignNeeded = true;
3256-
break;
3257-
}
3258-
3259-
for (const User *U : WorkList[I]->users())
3260-
WorkList.insert(cast<Instruction>(U));
3261-
}
3262-
auto *New = CallBase::removeOperandBundle(II, OBU.getTagID());
3263-
return New;
3264-
}
32653229
}
32663230

32673231
// Convert nonnull assume like:

llvm/lib/Transforms/Scalar/EarlyCSE.cpp

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,12 +1609,48 @@ bool EarlyCSE::processNode(DomTreeNode *Node) {
16091609
if (Inst.hasMetadata(LLVMContext::MD_noundef)) {
16101610
if (auto *AlignMD = Inst.getMetadata(LLVMContext::MD_align)) {
16111611
Inst.setMetadata(LLVMContext::MD_align, nullptr);
1612-
auto *A = mdconst::extract<ConstantInt>(AlignMD->getOperand(0));
1612+
auto *B = mdconst::extract<ConstantInt>(AlignMD->getOperand(0));
16131613
auto KB = computeKnownBits(Op, SQ.DL);
16141614
unsigned AlignFromKB = 1 << KB.countMinTrailingZeros();
1615-
if (AlignFromKB < A->getZExtValue()) {
1616-
IRBuilder B(&Inst);
1617-
B.CreateAlignmentAssumption(SQ.DL, Op, A);
1615+
if (AlignFromKB < B->getZExtValue()) {
1616+
SetVector<const Value *> WorkList;
1617+
bool AlignNeeded = false;
1618+
for (const User *U : Op->users())
1619+
if (auto *I = dyn_cast<Instruction>(U))
1620+
WorkList.insert(I);
1621+
1622+
for (unsigned I = 0; I != WorkList.size(); ++I) {
1623+
auto *Curr = WorkList[I];
1624+
if (auto *LI = dyn_cast<LoadInst>(Curr)) {
1625+
if (LI->getAlign().value() < B->getZExtValue()) {
1626+
AlignNeeded = true;
1627+
break;
1628+
}
1629+
continue;
1630+
}
1631+
if (auto *SI = dyn_cast<StoreInst>(Curr)) {
1632+
if (SI->getAlign().value() < B->getZExtValue()) {
1633+
AlignNeeded = true;
1634+
break;
1635+
}
1636+
continue;
1637+
}
1638+
if (isa<ICmpInst>(Curr) && !isa<Constant>(cast<Instruction>(Curr)->getOperand(0)) && !isa<Constant>(cast<Instruction>(Curr)->getOperand(1))) {
1639+
AlignNeeded = true;
1640+
break;
1641+
}
1642+
if (WorkList.size() > 16) {
1643+
AlignNeeded = true;
1644+
break;
1645+
}
1646+
1647+
for (const User *U : Curr->users())
1648+
WorkList.insert(cast<Instruction>(U));
1649+
}
1650+
if (AlignNeeded) {
1651+
IRBuilder Builder(&Inst);
1652+
Builder.CreateAlignmentAssumption(SQ.DL, Op, B);
1653+
}
16181654
}
16191655
}
16201656
}

0 commit comments

Comments
 (0)