[llvm] [SCEV] Fold zext(C+A)<nsw> -> (sext(C) + zext(A))<nsw> if possible. (PR #142599)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 5 12:11:57 PDT 2025


================
@@ -1793,6 +1793,18 @@ const SCEV *ScalarEvolution::getZeroExtendExprImpl(const SCEV *Op, Type *Ty,
       return getAddExpr(Ops, SCEV::FlagNUW, Depth + 1);
     }
 
+    const SCEVConstant *C;
+    const SCEV *A;
+    // zext (C + A)<nsw> -> (sext(C) + zext(A))<nsw> if zext (C + A)<nsw> >=s 0
+    // and A >=s V.
----------------
fhahn wrote:

Sounds good, so should we go with the current version then straight away or first land the restricted version which is less likely to intoduce any regressions?

https://github.com/llvm/llvm-project/pull/142599


More information about the llvm-commits mailing list