[llvm] [SCEV] Preserve divisibility info when creating UMax/SMax expressions. (PR #160012)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 8 14:45:21 PDT 2025


================
@@ -15865,17 +15825,23 @@ void ScalarEvolution::LoopGuards::collectFromBlock(
           EnqueueOperands(SMax);
         break;
       case CmpInst::ICMP_UGT:
-      case CmpInst::ICMP_UGE:
-        To = SE.getUMaxExpr(FromRewritten, RHS);
+      case CmpInst::ICMP_UGE: {
+        const SCEV *OpAlignedUp =
+            DividesBy ? GetNextSCEVDividesByDivisor(RHS, DividesBy) : RHS;
+        To = SE.getUMaxExpr(FromRewritten, OpAlignedUp);
----------------
nikic wrote:

Actually, are the changes here necessary at all? It looks like we are already doing these next/prev divisor adjustments for RHS in the switch above this. Maybe the generalization of the divisor logic is sufficient?

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


More information about the llvm-commits mailing list