[llvm] [IR] Reject unhandled assume bundles and seperate them from normal attributes (PR #197007)
Nikolas Klauser via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 4 05:17:56 PDT 2026
================
@@ -3647,66 +3648,45 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
return eraseInstFromFunction(*II);
}
- for (unsigned Idx = 0; Idx < II->getNumOperandBundles(); Idx++) {
- OperandBundleUse OBU = II->getOperandBundleAt(Idx);
+ for (auto [Idx, OBU] : llvm::enumerate(II->operand_bundles())) {
+ switch (getBundleAttrFromOBU(OBU)) {
+ case BundleAttr::None:
+ llvm_unreachable("Unexpected Attribute");
+ case BundleAttr::Align: {
+ // Try to remove redundant alignment assumptions.
+ auto [Ptr, _, Alignment, Offset] = getAssumeAlignInfo(OBU);
- // Separate storage assumptions apply to the underlying allocations, not
- // any particular pointer within them. When evaluating the hints for AA
- // purposes we getUnderlyingObject them; by precomputing the answers here
- // we can avoid having to do so repeatedly there.
- if (OBU.getTagName() == "separate_storage") {
- assert(OBU.Inputs.size() == 2);
- auto MaybeSimplifyHint = [&](const Use &U) {
- Value *Hint = U.get();
- // Not having a limit is safe because InstCombine removes unreachable
- // code.
- Value *UnderlyingObject = getUnderlyingObject(Hint, /*MaxLookup*/ 0);
- if (Hint != UnderlyingObject)
- replaceUse(const_cast<Use &>(U), UnderlyingObject);
- };
- MaybeSimplifyHint(OBU.Inputs[0]);
- MaybeSimplifyHint(OBU.Inputs[1]);
- }
-
- // Try to remove redundant alignment assumptions.
- if (OBU.getTagName() == "align" && OBU.Inputs.size() == 2) {
- RetainedKnowledge RK = getKnowledgeFromOperandInAssume(
- *cast<AssumeInst>(II), II->arg_size() + Idx);
- if (!RK || RK.AttrKind != Attribute::Alignment ||
- !isPowerOf2_64(RK.ArgValue) || !isa<ConstantInt>(RK.IRArgValue))
- continue;
+ if (Offset || !Alignment || !isPowerOf2_64(*Alignment))
----------------
philnik777 wrote:
I don't think it's a correctness issue here, though definitely unintentional. We lose some information about `Offset`, but all the simplifications below still hold. Anyways, I've added a test to show that we're not simplifying it for now and we can look at it in a separate PR. (Though it looks like the knowledge retention framework has another bug...)
https://github.com/llvm/llvm-project/pull/197007
More information about the llvm-commits
mailing list