[llvm] r316979 - [IRCE][NFC] Rename fields of InductiveRangeCheck

Max Kazantsev via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 30 23:19:05 PDT 2017


Author: mkazantsev
Date: Mon Oct 30 23:19:05 2017
New Revision: 316979

URL: http://llvm.org/viewvc/llvm-project?rev=316979&view=rev
Log:
[IRCE][NFC] Rename fields of InductiveRangeCheck

Rename `Offset`, `Scale`, `Length` into `Begin`, `Step`, `End` respectively
to make naming of similar entities for Ranges and Range Checks more
consistent.

Differential Revision: https://reviews.llvm.org/D39414

Modified:
    llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
    llvm/trunk/test/Transforms/IRCE/only-lower-check.ll
    llvm/trunk/test/Transforms/IRCE/only-upper-check.ll

Modified: llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp?rev=316979&r1=316978&r2=316979&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp Mon Oct 30 23:19:05 2017
@@ -149,9 +149,9 @@ class InductiveRangeCheck {
 
   static StringRef rangeCheckKindToStr(RangeCheckKind);
 
-  const SCEV *Offset = nullptr;
-  const SCEV *Scale = nullptr;
-  const SCEV *Length = nullptr;
+  const SCEV *Begin = nullptr;
+  const SCEV *Step = nullptr;
+  const SCEV *End = nullptr;
   Use *CheckUse = nullptr;
   RangeCheckKind Kind = RANGE_CHECK_UNKNOWN;
   bool IsSigned = true;
@@ -166,21 +166,21 @@ class InductiveRangeCheck {
                              SmallPtrSetImpl<Value *> &Visited);
 
 public:
-  const SCEV *getOffset() const { return Offset; }
-  const SCEV *getScale() const { return Scale; }
-  const SCEV *getLength() const { return Length; }
+  const SCEV *getBegin() const { return Begin; }
+  const SCEV *getStep() const { return Step; }
+  const SCEV *getEnd() const { return End; }
   bool isSigned() const { return IsSigned; }
 
   void print(raw_ostream &OS) const {
     OS << "InductiveRangeCheck:\n";
     OS << "  Kind: " << rangeCheckKindToStr(Kind) << "\n";
-    OS << "  Offset: ";
-    Offset->print(OS);
-    OS << "  Scale: ";
-    Scale->print(OS);
-    OS << "  Length: ";
-    if (Length)
-      Length->print(OS);
+    OS << "  Begin: ";
+    Begin->print(OS);
+    OS << "  Step: ";
+    Step->print(OS);
+    OS << "  End: ";
+    if (End)
+      End->print(OS);
     else
       OS << "(null)";
     OS << "\n  CheckUse: ";
@@ -379,8 +379,8 @@ void InductiveRangeCheck::extractRangeCh
       // checking the upper and lower bounds into a full range check.
       const auto &RChkA = SubChecks[0];
       const auto &RChkB = SubChecks[1];
-      if ((RChkA.Length == RChkB.Length || !RChkA.Length || !RChkB.Length) &&
-          RChkA.Offset == RChkB.Offset && RChkA.Scale == RChkB.Scale &&
+      if ((RChkA.End == RChkB.End || !RChkA.End || !RChkB.End) &&
+          RChkA.Begin == RChkB.Begin && RChkA.Step == RChkB.Step &&
           RChkA.IsSigned == RChkB.IsSigned) {
         // If RChkA.Kind == RChkB.Kind then we just found two identical checks.
         // But if one of them is a RANGE_CHECK_LOWER and the other is a
@@ -388,7 +388,7 @@ void InductiveRangeCheck::extractRangeCh
         // together they form a RANGE_CHECK_BOTH.
         SubChecks[0].Kind =
             (InductiveRangeCheck::RangeCheckKind)(RChkA.Kind | RChkB.Kind);
-        SubChecks[0].Length = RChkA.Length ? RChkA.Length : RChkB.Length;
+        SubChecks[0].End = RChkA.End ? RChkA.End : RChkB.End;
         SubChecks[0].CheckUse = &ConditionUse;
         SubChecks[0].IsSigned = RChkA.IsSigned;
 
@@ -419,9 +419,9 @@ void InductiveRangeCheck::extractRangeCh
     return;
 
   InductiveRangeCheck IRC;
-  IRC.Length = Length ? SE.getSCEV(Length) : nullptr;
-  IRC.Offset = IndexAddRec->getStart();
-  IRC.Scale = IndexAddRec->getStepRecurrence(SE);
+  IRC.End = Length ? SE.getSCEV(Length) : nullptr;
+  IRC.Begin = IndexAddRec->getStart();
+  IRC.Step = IndexAddRec->getStepRecurrence(SE);
   IRC.CheckUse = &ConditionUse;
   IRC.Kind = RCKind;
   IRC.IsSigned = IsSigned;
@@ -1615,7 +1615,7 @@ InductiveRangeCheck::computeSafeIteratio
   // IndVar is of the form "A + B * I" (where "I" is the canonical induction
   // variable, that may or may not exist as a real llvm::Value in the loop) and
   // this inductive range check is a range check on the "C + D * I" ("C" is
-  // getOffset() and "D" is getScale()).  We rewrite the value being range
+  // getBegin() and "D" is getStep()).  We rewrite the value being range
   // checked to "M + N * IndVar" where "N" = "D * B^(-1)" and "M" = "C - NA".
   //
   // The actual inequalities we solve are of the form
@@ -1647,8 +1647,8 @@ InductiveRangeCheck::computeSafeIteratio
     return None;
   assert(!B->isZero() && "Recurrence with zero step?");
 
-  const SCEV *C = getOffset();
-  const SCEVConstant *D = dyn_cast<SCEVConstant>(getScale());
+  const SCEV *C = getBegin();
+  const SCEVConstant *D = dyn_cast<SCEVConstant>(getStep());
   if (D != B)
     return None;
 
@@ -1660,7 +1660,7 @@ InductiveRangeCheck::computeSafeIteratio
 
   // We strengthen "0 <= I" to "0 <= I < INT_SMAX" and "I < L" to "0 <= I < L".
   // We can potentially do much better here.
-  if (const SCEV *L = getLength())
+  if (const SCEV *L = getEnd())
     UpperLimit = L;
   else {
     assert(Kind == InductiveRangeCheck::RANGE_CHECK_LOWER && "invariant!");

Modified: llvm/trunk/test/Transforms/IRCE/only-lower-check.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IRCE/only-lower-check.ll?rev=316979&r1=316978&r2=316979&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/IRCE/only-lower-check.ll (original)
+++ llvm/trunk/test/Transforms/IRCE/only-lower-check.ll Mon Oct 30 23:19:05 2017
@@ -3,7 +3,7 @@
 ; CHECK: irce: loop has 1 inductive range checks:
 ; CHECK-NEXT: InductiveRangeCheck:
 ; CHECK-NEXT:   Kind: RANGE_CHECK_LOWER
-; CHECK-NEXT:   Offset: (-1 + %n)  Scale: -1  Length: (null)
+; CHECK-NEXT:   Begin: (-1 + %n)  Step: -1  End: (null)
 ; CHECK-NEXT:   CheckUse:   br i1 %abc, label %in.bounds, label %out.of.bounds, !prof !1 Operand: 0
 ; CHECK-NEXT: irce: in function only_lower_check: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
 

Modified: llvm/trunk/test/Transforms/IRCE/only-upper-check.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IRCE/only-upper-check.ll?rev=316979&r1=316978&r2=316979&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/IRCE/only-upper-check.ll (original)
+++ llvm/trunk/test/Transforms/IRCE/only-upper-check.ll Mon Oct 30 23:19:05 2017
@@ -3,7 +3,7 @@
 ; CHECK: irce: loop has 1 inductive range checks:
 ; CHECK-NEXT:InductiveRangeCheck:
 ; CHECK-NEXT:  Kind: RANGE_CHECK_UPPER
-; CHECK-NEXT:  Offset: %offset  Scale: 1  Length:   %len
+; CHECK-NEXT:  Begin: %offset  Step: 1  End:   %len
 ; CHECK-NEXT:  CheckUse:   br i1 %abc, label %in.bounds, label %out.of.bounds, !prof !1 Operand: 0
 ; CHECK-NEXT: irce: in function incrementing: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
 




More information about the llvm-commits mailing list