[llvm-branch-commits] [llvm] [DA] Check nsw when extracting a constant operand of SCEVMul (PR #164408)
Michael Kruse via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Oct 28 07:35:10 PDT 2025
================
@@ -2828,8 +2828,9 @@ static std::optional<APInt> getConstantPart(const SCEV *Expr) {
if (const auto *Constant = dyn_cast<SCEVConstant>(Expr))
return Constant->getAPInt();
if (const auto *Product = dyn_cast<SCEVMulExpr>(Expr))
- if (const auto *Constant = dyn_cast<SCEVConstant>(Product->getOperand(0)))
- return Constant->getAPInt();
+ if (Product->hasNoSignedWrap())
----------------
Meinersbur wrote:
Could you update the function comment, maybe even the function name? This returns the (constant) coefficent/slope of a linear function. Without NSW, it is still a "constant part", just not the slope of a linear function.
Suggestion: `getConstCoefficent`, like at those places where it is called.
https://github.com/llvm/llvm-project/pull/164408
More information about the llvm-branch-commits
mailing list