Skip to content

Commit e103d62

Browse files
committed
step
1 parent 9ac479d commit e103d62

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3233,21 +3233,35 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
32333233
if (!RK || RK.AttrKind != Attribute::Alignment ||
32343234
!isPowerOf2_64(RK.ArgValue))
32353235
continue;
3236-
SetVector<const Instruction *> WorkList;
3236+
SetVector<const Value *> WorkList;
32373237
bool AlignNeeded = false;
3238-
WorkList.insert(II);
3238+
for (const User *U : RK.WasOn->users())
3239+
WorkList.insert(cast<Instruction>(U));
3240+
32393241
for (unsigned I = 0; I != WorkList.size(); ++I) {
3240-
if (auto *LI = dyn_cast<LoadInst>(WorkList[I])) {
3242+
auto *Curr = WorkList[I];
3243+
if (auto *LI = dyn_cast<LoadInst>(Curr)) {
32413244
if (auto *AlignMD = LI->getMetadata(LLVMContext::MD_align)) {
32423245
auto *A = mdconst::extract<ConstantInt>(AlignMD->getOperand(0));
32433246

32443247
if (A->getZExtValue() % RK.ArgValue != 0) {
32453248
AlignNeeded = true;
32463249
break;
32473250
}
3251+
3252+
if (LI->getAlign().value() < RK.ArgValue) {
3253+
AlignNeeded = true;
3254+
break;
3255+
}
3256+
}
3257+
}
3258+
if (auto *SI = dyn_cast<StoreInst>(Curr)) {
3259+
if (SI->getAlign().value() < RK.ArgValue) {
3260+
AlignNeeded = true;
3261+
break;
32483262
}
32493263
}
3250-
if (isa<ICmpInst>(WorkList[I])) {
3264+
if (isa<ICmpInst>(Curr) && !isa<Constant>(cast<Instruction>(Curr)->getOperand(0)) && !isa<Constant>(cast<Instruction>(Curr)->getOperand(1))) {
32513265
AlignNeeded = true;
32523266
break;
32533267
}
@@ -3256,11 +3270,13 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
32563270
break;
32573271
}
32583272

3259-
for (const User *U : WorkList[I]->users())
3273+
for (const User *U : Curr->users())
32603274
WorkList.insert(cast<Instruction>(U));
32613275
}
3262-
auto *New = CallBase::removeOperandBundle(II, OBU.getTagID());
3263-
return New;
3276+
if (!AlignNeeded) {
3277+
auto *New = CallBase::removeOperandBundle(II, OBU.getTagID());
3278+
return New;
3279+
}
32643280
}
32653281
}
32663282

0 commit comments

Comments
 (0)