[llvm] [LAA,Loads] Use loop guards and max BTC if needed when checking deref. (PR #155672)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 28 08:07:36 PDT 2025
================
@@ -2338,23 +2338,15 @@ bool ScalarEvolution::willNotOverflow(Instruction::BinaryOps BinOp, bool Signed,
// Can we use context to prove the fact we need?
if (!CtxI)
return false;
+ // TODO: Support mul.
+ if (BinOp == Instruction::Mul)
+ return false;
auto *RHSC = dyn_cast<SCEVConstant>(RHS);
// TODO: Lift this limitation.
if (!RHSC)
return false;
APInt C = RHSC->getAPInt();
unsigned NumBits = C.getBitWidth();
- if (BinOp == Instruction::Mul) {
- // Multiplying by 0 or 1 never overflows
- if (C.isZero() || C.isOne())
- return true;
- if (Signed)
- return false;
- APInt Limit = APInt::getMaxValue(NumBits).udiv(C);
- // To avoid overflow, we need to make sure that LHS <= MAX / C.
- return isKnownPredicateAt(ICmpInst::ICMP_ULE, LHS, getConstant(Limit),
- CtxI);
- }
----------------
fhahn wrote:
That would be great. If there are, could you add them?
https://github.com/llvm/llvm-project/pull/155672
More information about the llvm-commits
mailing list