[llvm] [InstCombine] Fold align assume into load's !align metadata if possible. (PR #108958)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 17 05:18:43 PDT 2024
================
@@ -3095,6 +3096,23 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
MaybeSimplifyHint(OBU.Inputs[0]);
MaybeSimplifyHint(OBU.Inputs[1]);
}
+
+ // Try to fold alignment assumption into a load's !align metadata, if the
+ // assumption is valid in the load's context.
+ if (OBU.getTagName() == "align" && OBU.Inputs.size() == 2) {
+ auto *LI = dyn_cast<LoadInst>(OBU.Inputs[0]);
+ if (!LI ||
+ !isValidAssumeForContext(II, LI, &DT, /*AllowEphemerals=*/true))
+ continue;
+ auto *Align = cast<ConstantInt>(OBU.Inputs[1]);
+ if (!isPowerOf2_64(Align->getZExtValue()))
----------------
fhahn wrote:
> Can we use getKnowledgeFromBundle here?
Missed this earlier, updated now, thanks!
https://github.com/llvm/llvm-project/pull/108958
More information about the llvm-commits
mailing list