[llvm] [SECV] Try to push the op into ZExt: A + zext (-A + B) -> zext (B) (PR #151227)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 31 04:48:18 PDT 2025
================
@@ -2682,6 +2682,21 @@ const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops,
return getAddExpr(NewOps, PreservedFlags);
}
}
+
+ // Try to push the constant operand into a ZExt: A + zext (-A + B) -> zext
+ // (B), if trunc (A) + -A + B does not unsigned-wrap.
+ if (auto *ZExt = dyn_cast<SCEVZeroExtendExpr>(Ops[1])) {
+ const SCEV *B = ZExt->getOperand(0);
+ const SCEV *NarrowA = getTruncateExpr(A, B->getType());
----------------
fhahn wrote:
Thanks, should be done in ab9b23c446531f5d9f081123c9f2fde4e8a334eb by introducing a new `m_scec_Add()` which matches and captures SCEVAddExpr with an abitrary number of operands
https://github.com/llvm/llvm-project/pull/151227
More information about the llvm-commits
mailing list