[llvm] [LAA,Loads] Use loop guards and max BTC if needed when checking deref. (PR #155672)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 2 06:46:57 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);
- }
----------------
annamthomas wrote:
In my cases as well, https://github.com/llvm/llvm-project/pull/155300 was enough. We can remove this.
https://github.com/llvm/llvm-project/pull/155672
More information about the llvm-commits
mailing list