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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 9 02:07:04 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);
----------------
fhahn wrote:

Yep it looks like we get all the benfits from the patch with just the switch to getConstantMultiple: https://github.com/llvm/llvm-project/pull/162617

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


More information about the llvm-commits mailing list