[PATCH] D34672: [IRCE][NFC] Better get SCEV for 1 in calculateSubRanges

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 27 02:01:03 PDT 2017


mkazantsev created this revision.

A slightly more efficient way to get constant, we avoid creation of a ConstantInt, resolving in getSCEV and excessive invocations.


https://reviews.llvm.org/D34672

Files:
  lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp


Index: lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
===================================================================
--- lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
+++ lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
@@ -917,7 +917,6 @@
   // I think we can be more aggressive here and make this nuw / nsw if the
   // addition that feeds into the icmp for the latch's terminating branch is nuw
   // / nsw.  In any case, a wrapping 2's complement addition is safe.
-  ConstantInt *One = ConstantInt::get(Ty, 1);
   const SCEV *Start = SE.getSCEV(MainLoopStructure.IndVarStart);
   const SCEV *End = SE.getSCEV(MainLoopStructure.LoopExitAt);
 
@@ -948,8 +947,9 @@
     //    will be an empty range.  Returning an empty range is always safe.
     //
 
-    Smallest = SE.getAddExpr(End, SE.getSCEV(One));
-    Greatest = SE.getAddExpr(Start, SE.getSCEV(One));
+    const SCEV *One = SE.getOne(Ty);
+    Smallest = SE.getAddExpr(End, One);
+    Greatest = SE.getAddExpr(Start, One);
   }
 
   auto Clamp = [this, Smallest, Greatest](const SCEV *S) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34672.104107.patch
Type: text/x-patch
Size: 1085 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170627/96b50613/attachment.bin>


More information about the llvm-commits mailing list