File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
llvm/lib/Transforms/InstCombine Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -3226,6 +3226,42 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
3226
3226
MaybeSimplifyHint (OBU.Inputs [0 ]);
3227
3227
MaybeSimplifyHint (OBU.Inputs [1 ]);
3228
3228
}
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
+ }
3229
3265
}
3230
3266
3231
3267
// Convert nonnull assume like:
You can’t perform that action at this time.
0 commit comments