[llvm] r316889 - [IRCE][NFC] Store Length as SCEV in RangeCheck instead of Value

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 30 10:37:13 PDT 2017


minor follow up suggestion below


On 10/30/2017 02:35 AM, Max Kazantsev via llvm-commits wrote:
> Author: mkazantsev
> Date: Mon Oct 30 02:35:16 2017
> New Revision: 316889
>
> URL: http://llvm.org/viewvc/llvm-project?rev=316889&view=rev
> Log:
> [IRCE][NFC] Store Length as SCEV in RangeCheck instead of Value
>
> Modified:
>      llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
>      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=316889&r1=316888&r2=316889&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp Mon Oct 30 02:35:16 2017
> @@ -151,7 +151,7 @@ class InductiveRangeCheck {
>   
>     const SCEV *Offset = nullptr;
>     const SCEV *Scale = nullptr;
> -  Value *Length = nullptr;
> +  const SCEV *Length = nullptr;
>     Use *CheckUse = nullptr;
>     RangeCheckKind Kind = RANGE_CHECK_UNKNOWN;
>     bool IsSigned = true;
> @@ -168,7 +168,7 @@ class InductiveRangeCheck {
>   public:
>     const SCEV *getOffset() const { return Offset; }
>     const SCEV *getScale() const { return Scale; }
> -  Value *getLength() const { return Length; }
> +  const SCEV *getLength() const { return Length; }
>     bool isSigned() const { return IsSigned; }
>   
>     void print(raw_ostream &OS) const {
> @@ -419,7 +419,7 @@ void InductiveRangeCheck::extractRangeCh
>       return;
>   
>     InductiveRangeCheck IRC;
> -  IRC.Length = Length;
> +  IRC.Length = Length ? SE.getSCEV(Length) : nullptr;
(mark - referenced later)
>     IRC.Offset = IndexAddRec->getStart();
>     IRC.Scale = IndexAddRec->getStepRecurrence(SE);
>     IRC.CheckUse = &ConditionUse;
> @@ -1660,9 +1660,9 @@ 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 (Value *V = getLength()) {
> -    UpperLimit = SE.getSCEV(V);
> -  } else {
> +  if (const SCEV *L = getLength())
> +    UpperLimit = L;
> +  else {
>       assert(Kind == InductiveRangeCheck::RANGE_CHECK_LOWER && "invariant!");
>       unsigned BitWidth = cast<IntegerType>(IndVar->getType())->getBitWidth();
>       UpperLimit = SE.getConstant(APInt::getSignedMaxValue(BitWidth));
Can this block of code be moved to "mark"?  It looks like we do always 
have a SCEV here.  The assert also seems a bit disconnected, having it 
closer to the code which ensures this would be helpful. For instance, 
it's not immediately clear to me why a signed max is correct here.
>
> 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=316889&r1=316888&r2=316889&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/IRCE/only-upper-check.ll (original)
> +++ llvm/trunk/test/Transforms/IRCE/only-upper-check.ll Mon Oct 30 02:35:16 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 = load i32, i32* %a_len_ptr, !range !0
> +; CHECK-NEXT:  Offset: %offset  Scale: 1  Length:   %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>
>   
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list