[llvm] 68ba286 - [SCEVExp] Remove early exit, rely on InstSimplifyFolder (NFCI).

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 21 13:39:59 PST 2025


Author: Florian Hahn
Date: 2025-11-21T21:38:35Z
New Revision: 68ba2864d936a59ac1e382f754a15b975b04900d

URL: https://github.com/llvm/llvm-project/commit/68ba2864d936a59ac1e382f754a15b975b04900d
DIFF: https://github.com/llvm/llvm-project/commit/68ba2864d936a59ac1e382f754a15b975b04900d.diff

LOG: [SCEVExp] Remove early exit, rely on InstSimplifyFolder (NFCI).

Remove the SCEV-based check refined in
https://github.com/llvm/llvm-project/pull/156910, as InstSimplifyFolder
manages to simplify the generated code to false directly as well.

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index 9035e58a707c4..54e26b2e94c1c 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -2208,17 +2208,6 @@ Value *SCEVExpander::generateOverflowCheck(const SCEVAddRecExpr *AR,
   // negative. If Step is known to be positive or negative, only create
   // either 1. or 2.
   auto ComputeEndCheck = [&]() -> Value * {
-    // Checking <u 0 is always false, if (Step * trunc ExitCount) does not wrap.
-    // TODO: Predicates that can be proven true/false should be discarded when
-    // the predicates are created, not late during expansion.
-    if (!Signed && Start->isZero() && SE.isKnownPositive(Step) &&
-        DstBits < SrcBits &&
-        ExitCount == SE.getZeroExtendExpr(SE.getTruncateExpr(ExitCount, ARTy),
-                                          ExitCount->getType()) &&
-        SE.willNotOverflow(Instruction::Mul, Signed, Step,
-                           SE.getTruncateExpr(ExitCount, ARTy)))
-      return ConstantInt::getFalse(Loc->getContext());
-
     // Get the backedge taken count and truncate or extended to the AR type.
     Value *TruncTripCount = Builder.CreateZExtOrTrunc(TripCountVal, Ty);
 


        


More information about the llvm-commits mailing list