[PATCH] D90926: [SCEV] Don't use not expressions for implied conditions

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 6 03:16:21 PST 2020


nikic created this revision.
Herald added subscribers: llvm-commits, javed.absar, hiraditya.
Herald added a project: LLVM.
nikic requested review of this revision.

SCEV currently tries to prove implications of `x pred y` by also trying to imply `~y pred ~x`. This is expensive in terms of compile-time (in fact, the vast majority of isImpliedCond compile-time is wasted here), but has little chance of proving anything useful (the operand swap breaks canonicalization, so constants and addrecs will not line up with the other condition anymore). I'm sure there's some case for which the general idea here is useful for, but this is not the right way to go about it.

Compile-time: https://llvm-compile-time-tracker.com/compare.php?from=afe92642cc73db48ea46a1dc1a534492249040a7&to=99efe1e8fff2f3e92828f624f109d0190a9d7f59&stat=instructions


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90926

Files:
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/test/Analysis/ScalarEvolution/zext-wrap.ll


Index: llvm/test/Analysis/ScalarEvolution/zext-wrap.ll
===================================================================
--- llvm/test/Analysis/ScalarEvolution/zext-wrap.ll
+++ llvm/test/Analysis/ScalarEvolution/zext-wrap.ll
@@ -15,7 +15,7 @@
 
 ; This cast shouldn't be folded into the addrec.
 ; CHECK: %tmp = zext i8 %l_95.0.i1 to i16
-; CHECK: -->  (zext i8 {0,+,-1}<nw><%bb.i> to i16){{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: 2
+; CHECK: -->  (zext i8 {0,+,-1}<%bb.i> to i16){{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: 2
 
         %tmp = zext i8 %l_95.0.i1 to i16
 
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -10547,11 +10547,7 @@
     return true;
 
   return isImpliedCondOperandsHelper(Pred, LHS, RHS,
-                                     FoundLHS, FoundRHS) ||
-         // ~x < ~y --> x > y
-         isImpliedCondOperandsHelper(Pred, LHS, RHS,
-                                     getNotSCEV(FoundRHS),
-                                     getNotSCEV(FoundLHS));
+                                     FoundLHS, FoundRHS);
 }
 
 /// Is MaybeMinMaxExpr an (U|S)(Min|Max) of Candidate and some other values?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90926.303388.patch
Type: text/x-patch
Size: 1263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201106/6ccf7461/attachment.bin>


More information about the llvm-commits mailing list