[llvm] 3f0e1d4 - [SCEV] Swap order of arguments to MatchBinaryAddToConst (NFCI). (#91945)

via llvm-commits llvm-commits at lists.llvm.org
Mon May 13 05:04:25 PDT 2024


Author: Florian Hahn
Date: 2024-05-13T13:04:22+01:00
New Revision: 3f0e1d4cf09b0c90abfb1d06a26cc4c85c1f9568

URL: https://github.com/llvm/llvm-project/commit/3f0e1d4cf09b0c90abfb1d06a26cc4c85c1f9568
DIFF: https://github.com/llvm/llvm-project/commit/3f0e1d4cf09b0c90abfb1d06a26cc4c85c1f9568.diff

LOG: [SCEV] Swap order of arguments to MatchBinaryAddToConst (NFCI). (#91945)

The argument order to MatchBinaryAddToConst doesn't match the comment
and also is counter-intuitive (passing RHS before LHS, C2 before C1).

This patch adjusts the order to be inline with the calls above, which
should be equivalent, but more natural:
https://alive2.llvm.org/ce/z/ZWGp-Z

PR: https://github.com/llvm/llvm-project/pull/91945

Added: 
    

Modified: 
    llvm/lib/Analysis/ScalarEvolution.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 7dc5aa084f3c3..254d79183a1e9 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -11274,7 +11274,7 @@ bool ScalarEvolution::isKnownPredicateViaNoOverflow(ICmpInst::Predicate Pred,
     [[fallthrough]];
   case ICmpInst::ICMP_ULE:
     // (X + C1)<nuw> u<= (X + C2)<nuw> for C1 u<= C2.
-    if (MatchBinaryAddToConst(RHS, LHS, C2, C1, SCEV::FlagNUW) && C1.ule(C2))
+    if (MatchBinaryAddToConst(LHS, RHS, C1, C2, SCEV::FlagNUW) && C1.ule(C2))
       return true;
 
     break;
@@ -11284,7 +11284,7 @@ bool ScalarEvolution::isKnownPredicateViaNoOverflow(ICmpInst::Predicate Pred,
     [[fallthrough]];
   case ICmpInst::ICMP_ULT:
     // (X + C1)<nuw> u< (X + C2)<nuw> if C1 u< C2.
-    if (MatchBinaryAddToConst(RHS, LHS, C2, C1, SCEV::FlagNUW) && C1.ult(C2))
+    if (MatchBinaryAddToConst(LHS, RHS, C1, C2, SCEV::FlagNUW) && C1.ult(C2))
       return true;
     break;
   }


        


More information about the llvm-commits mailing list