[llvm] r336140 - [SCEV] Strengthen StrengthenNoWrapFlags (reapply r334428).

Amara Emerson via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 4 10:27:25 PDT 2018


Hi Tim,

It looks like this change affects some CTMark compile time metrics. The exact amount varies depending on the build configuration, but CTMark/mafft/pairlocalalign regresses by about 2-3% consistently, and CTMark/lencod/lencod also seems to regress by about 1% too. Not necessarily blocking this commit, but letting you know it had an effect in case there’s anything you can do to improve it.

Cheers,
Amara

> On Jul 2, 2018, at 9:01 PM, Tim Shen via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> 
> Author: timshen
> Date: Mon Jul  2 13:01:54 2018
> New Revision: 336140
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=336140&view=rev
> Log:
> [SCEV] Strengthen StrengthenNoWrapFlags (reapply r334428).
> 
> Summary:
> Comment on Transforms/LoopVersioning/incorrect-phi.ll: With the change
> SCEV is able to prove that the loop doesn't wrap-self (due to zext i16
> to i64), disabling the entire loop versioning pass. Removed the zext and
> just use i64.
> 
> Reviewers: sanjoy
> 
> Subscribers: jlebar, hiraditya, javed.absar, bixia, llvm-commits
> 
> Differential Revision: https://reviews.llvm.org/D48409
> 
> Modified:
>    llvm/trunk/lib/Analysis/ScalarEvolution.cpp
>    llvm/trunk/test/Analysis/Delinearization/a.ll
>    llvm/trunk/test/Analysis/Delinearization/iv_times_constant_in_subscript.ll
>    llvm/trunk/test/Analysis/IVUsers/quadradic-exit-value.ll
>    llvm/trunk/test/Analysis/LoopAccessAnalysis/number-of-memchecks.ll
>    llvm/trunk/test/Analysis/LoopAccessAnalysis/wrapping-pointer-versioning.ll
>    llvm/trunk/test/Analysis/ScalarEvolution/different-loops-recs.ll
>    llvm/trunk/test/Analysis/ScalarEvolution/extract-highbits-sameconstmask.ll
>    llvm/trunk/test/Analysis/ScalarEvolution/lshr-shl-differentconstmask.ll
>    llvm/trunk/test/Analysis/ScalarEvolution/nsw-offset-assume.ll
>    llvm/trunk/test/Analysis/ScalarEvolution/nsw-offset.ll
>    llvm/trunk/test/Analysis/ScalarEvolution/nsw.ll
>    llvm/trunk/test/Analysis/ScalarEvolution/predicated-trip-count.ll
>    llvm/trunk/test/Analysis/ScalarEvolution/sext-mul.ll
>    llvm/trunk/test/Analysis/ScalarEvolution/shl-lshr-differentconstmask.ll
>    llvm/trunk/test/Analysis/ScalarEvolution/trip-count-pow2.ll
>    llvm/trunk/test/Analysis/ScalarEvolution/zext-mul.ll
>    llvm/trunk/test/Transforms/LoopVersioning/incorrect-phi.ll
> 
> Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
> +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Jul  2 13:01:54 2018
> @@ -2247,22 +2247,35 @@ StrengthenNoWrapFlags(ScalarEvolution *S
> 
>   SignOrUnsignWrap = ScalarEvolution::maskFlags(Flags, SignOrUnsignMask);
> 
> -  if (SignOrUnsignWrap != SignOrUnsignMask && Type == scAddExpr &&
> -      Ops.size() == 2 && isa<SCEVConstant>(Ops[0])) {
> +  if (SignOrUnsignWrap != SignOrUnsignMask &&
> +      (Type == scAddExpr || Type == scMulExpr) && Ops.size() == 2 &&
> +      isa<SCEVConstant>(Ops[0])) {
> 
> -    // (A + C) --> (A + C)<nsw> if the addition does not sign overflow
> -    // (A + C) --> (A + C)<nuw> if the addition does not unsign overflow
> +    auto Opcode = [&] {
> +      switch (Type) {
> +      case scAddExpr:
> +        return Instruction::Add;
> +      case scMulExpr:
> +        return Instruction::Mul;
> +      default:
> +        llvm_unreachable("Unexpected SCEV op.");
> +      }
> +    }();
> 
>     const APInt &C = cast<SCEVConstant>(Ops[0])->getAPInt();
> +
> +    // (A <opcode> C) --> (A <opcode> C)<nsw> if the op doesn't sign overflow.
>     if (!(SignOrUnsignWrap & SCEV::FlagNSW)) {
>       auto NSWRegion = ConstantRange::makeGuaranteedNoWrapRegion(
> -          Instruction::Add, C, OBO::NoSignedWrap);
> +          Opcode, C, OBO::NoSignedWrap);
>       if (NSWRegion.contains(SE->getSignedRange(Ops[1])))
>         Flags = ScalarEvolution::setFlags(Flags, SCEV::FlagNSW);
>     }
> +
> +    // (A <opcode> C) --> (A <opcode> C)<nuw> if the op doesn't unsign overflow.
>     if (!(SignOrUnsignWrap & SCEV::FlagNUW)) {
>       auto NUWRegion = ConstantRange::makeGuaranteedNoWrapRegion(
> -          Instruction::Add, C, OBO::NoUnsignedWrap);
> +          Opcode, C, OBO::NoUnsignedWrap);
>       if (NUWRegion.contains(SE->getUnsignedRange(Ops[1])))
>         Flags = ScalarEvolution::setFlags(Flags, SCEV::FlagNUW);
>     }
> 
> Modified: llvm/trunk/test/Analysis/Delinearization/a.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/Delinearization/a.ll?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/test/Analysis/Delinearization/a.ll (original)
> +++ llvm/trunk/test/Analysis/Delinearization/a.ll Mon Jul  2 13:01:54 2018
> @@ -10,7 +10,7 @@
> ; AddRec: {{{(28 + (4 * (-4 + (3 * %m)) * %o) + %A),+,(8 * %m * %o)}<%for.i>,+,(12 * %o)}<%for.j>,+,20}<%for.k>
> ; CHECK: Base offset: %A
> ; CHECK: ArrayDecl[UnknownSize][%m][%o] with elements of 4 bytes.
> -; CHECK: ArrayRef[{3,+,2}<%for.i>][{-4,+,3}<nw><%for.j>][{7,+,5}<nw><%for.k>]
> +; CHECK: ArrayRef[{3,+,2}<nw><%for.i>][{-4,+,3}<nw><%for.j>][{7,+,5}<nw><%for.k>]
> 
> define void @foo(i64 %n, i64 %m, i64 %o, i32* nocapture %A) #0 {
> entry:
> 
> Modified: llvm/trunk/test/Analysis/Delinearization/iv_times_constant_in_subscript.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/Delinearization/iv_times_constant_in_subscript.ll?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/test/Analysis/Delinearization/iv_times_constant_in_subscript.ll (original)
> +++ llvm/trunk/test/Analysis/Delinearization/iv_times_constant_in_subscript.ll Mon Jul  2 13:01:54 2018
> @@ -11,7 +11,7 @@
> ; AddRec: {{((%m * %b * 8) + %A),+,(2 * %m * 8)}<%for.i>,+,(2 * 8)}<%for.j>
> ; CHECK: Base offset: %A
> ; CHECK: ArrayDecl[UnknownSize][%m] with elements of 8 bytes.
> -; CHECK: ArrayRef[{%b,+,2}<nsw><%for.i>][{0,+,2}<%for.j>]
> +; CHECK: ArrayRef[{%b,+,2}<nsw><%for.i>][{0,+,2}<nuw><%for.j>]
> 
> 
> define void @foo(i64 %n, i64 %m, i64 %b, double* %A) {
> 
> Modified: llvm/trunk/test/Analysis/IVUsers/quadradic-exit-value.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/IVUsers/quadradic-exit-value.ll?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/test/Analysis/IVUsers/quadradic-exit-value.ll (original)
> +++ llvm/trunk/test/Analysis/IVUsers/quadradic-exit-value.ll Mon Jul  2 13:01:54 2018
> @@ -70,7 +70,7 @@ exit:
> ; sure they aren't marked as post-inc users.
> ;
> ; CHECK-LABEL: IV Users for loop %test2.loop
> -; CHECK-NO-LCSSA: %sub.cond.us = ((-1 * %sub.us)<nsw> + {0,+,1}<nuw><nsw><%test2.loop>) (post-inc with loop %test2.loop) in    %sext.us = mul i32 %mul.us, %sub.cond.us
> +; CHECK-NO-LCSSA: %sub.cond.us = ((-1 * %sub.us)<nuw><nsw> + {0,+,1}<nuw><nsw><%test2.loop>) (post-inc with loop %test2.loop) in    %sext.us = mul i32 %mul.us, %sub.cond.us
> define i32 @test2() {
> entry:
>   br label %test2.loop
> 
> Modified: llvm/trunk/test/Analysis/LoopAccessAnalysis/number-of-memchecks.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/LoopAccessAnalysis/number-of-memchecks.ll?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/test/Analysis/LoopAccessAnalysis/number-of-memchecks.ll (original)
> +++ llvm/trunk/test/Analysis/LoopAccessAnalysis/number-of-memchecks.ll Mon Jul  2 13:01:54 2018
> @@ -251,10 +251,10 @@ for.end:
> ; CHECK-NEXT:         Member: {((2 * %offset) + %a)<nsw>,+,2}<nsw><%for.body>
> ; CHECK-NEXT:     Group {{.*}}[[ONE]]:
> ; CHECK-NEXT:       (Low: %a High: (10000 + %a))
> -; CHECK-NEXT:         Member: {%a,+,2}<%for.body>
> +; CHECK-NEXT:         Member: {%a,+,2}<nw><%for.body>
> ; CHECK-NEXT:     Group {{.*}}[[TWO]]:
> ; CHECK-NEXT:       (Low: (20000 + %a) High: (30000 + %a))
> -; CHECK-NEXT:         Member: {(20000 + %a),+,2}<%for.body>
> +; CHECK-NEXT:         Member: {(20000 + %a),+,2}<nw><%for.body>
> 
> define void @testi(i16* %a,
>                    i64 %offset) {
> 
> Modified: llvm/trunk/test/Analysis/LoopAccessAnalysis/wrapping-pointer-versioning.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/LoopAccessAnalysis/wrapping-pointer-versioning.ll?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/test/Analysis/LoopAccessAnalysis/wrapping-pointer-versioning.ll (original)
> +++ llvm/trunk/test/Analysis/LoopAccessAnalysis/wrapping-pointer-versioning.ll Mon Jul  2 13:01:54 2018
> @@ -33,7 +33,7 @@ target datalayout = "e-m:o-i64:64-f80:12
> ;    i64 {0,+,2}<%for.body>
> 
> ; LAA: [PSE]  %arrayidxA = getelementptr i16, i16* %a, i64 %mul_ext:
> -; LAA-NEXT: ((2 * (zext i32 {0,+,2}<%for.body> to i64)) + %a)
> +; LAA-NEXT: ((2 * (zext i32 {0,+,2}<%for.body> to i64))<nuw><nsw> + %a)
> ; LAA-NEXT: --> {%a,+,4}<%for.body>
> 
> 
> @@ -130,7 +130,7 @@ for.end:
> ;     i64 {zext i32 (2 * (trunc i64 %N to i32)) to i64,+,-2}<%for.body>
> 
> ; LAA: [PSE]  %arrayidxA = getelementptr i16, i16* %a, i64 %mul_ext:
> -; LAA-NEXT: ((2 * (zext i32 {(2 * (trunc i64 %N to i32)),+,-2}<%for.body> to i64)) + %a)
> +; LAA-NEXT: ((2 * (zext i32 {(2 * (trunc i64 %N to i32)),+,-2}<%for.body> to i64))<nuw><nsw> + %a)
> ; LAA-NEXT: --> {((4 * (zext i31 (trunc i64 %N to i31) to i64)) + %a),+,-4}<%for.body>
> 
> ; LV-LABEL: f2
> @@ -210,7 +210,7 @@ for.end:
> ;     i64 {0,+,2}<%for.body>
> 
> ; LAA: [PSE]  %arrayidxA = getelementptr i16, i16* %a, i64 %mul_ext:
> -; LAA-NEXT: ((2 * (sext i32 {0,+,2}<%for.body> to i64)) + %a)
> +; LAA-NEXT: ((2 * (sext i32 {0,+,2}<%for.body> to i64))<nsw> + %a)
> ; LAA-NEXT: --> {%a,+,4}<%for.body>
> 
> ; LV-LABEL: f3
> @@ -278,7 +278,7 @@ for.end:
> ; LAA: Memory dependences are safe{{$}}
> ; LAA: SCEV assumptions:
> ; LAA-NEXT: {(2 * (trunc i64 %N to i32)),+,-2}<%for.body> Added Flags: <nssw>
> -; LAA-NEXT: {((2 * (sext i32 (2 * (trunc i64 %N to i32)) to i64)) + %a),+,-4}<%for.body> Added Flags: <nusw>
> +; LAA-NEXT: {((2 * (sext i32 (2 * (trunc i64 %N to i32)) to i64))<nsw> + %a),+,-4}<%for.body> Added Flags: <nusw>
> 
> ; The expression for %mul_ext as analyzed by SCEV is
> ;     i64  (sext i32 {(2 * (trunc i64 %N to i32)),+,-2}<%for.body> to i64)
> @@ -286,8 +286,8 @@ for.end:
> ;     i64 {sext i32 (2 * (trunc i64 %N to i32)) to i64,+,-2}<%for.body>
> 
> ; LAA: [PSE]  %arrayidxA = getelementptr i16, i16* %a, i64 %mul_ext:
> -; LAA-NEXT: ((2 * (sext i32 {(2 * (trunc i64 %N to i32)),+,-2}<%for.body> to i64)) + %a)
> -; LAA-NEXT: --> {((2 * (sext i32 (2 * (trunc i64 %N to i32)) to i64)) + %a),+,-4}<%for.body>
> +; LAA-NEXT: ((2 * (sext i32 {(2 * (trunc i64 %N to i32)),+,-2}<%for.body> to i64))<nsw> + %a)
> +; LAA-NEXT: --> {((2 * (sext i32 (2 * (trunc i64 %N to i32)) to i64))<nsw> + %a),+,-4}<%for.body>
> 
> ; LV-LABEL: f4
> ; LV-LABEL: for.body.lver.check
> @@ -362,11 +362,11 @@ for.end:
> ; LAA: Memory dependences are safe{{$}}
> ; LAA: SCEV assumptions:
> ; LAA-NEXT: {(2 * (trunc i64 %N to i32)),+,-2}<%for.body> Added Flags: <nssw>
> -; LAA-NEXT: {((2 * (sext i32 (2 * (trunc i64 %N to i32)) to i64)) + %a),+,-4}<%for.body> Added Flags: <nusw>
> +; LAA-NEXT: {((2 * (sext i32 (2 * (trunc i64 %N to i32)) to i64))<nsw> + %a),+,-4}<%for.body> Added Flags: <nusw>
> 
> ; LAA: [PSE]  %arrayidxA = getelementptr inbounds i16, i16* %a, i32 %mul:
> ; LAA-NEXT: ((2 * (sext i32 {(2 * (trunc i64 %N to i32)),+,-2}<%for.body> to i64))<nsw> + %a)<nsw>
> -; LAA-NEXT: --> {((2 * (sext i32 (2 * (trunc i64 %N to i32)) to i64)) + %a),+,-4}<%for.body>
> +; LAA-NEXT: --> {((2 * (sext i32 (2 * (trunc i64 %N to i32)) to i64))<nsw> + %a),+,-4}<%for.body>
> 
> ; LV-LABEL: f5
> ; LV-LABEL: for.body.lver.check
> 
> Modified: llvm/trunk/test/Analysis/ScalarEvolution/different-loops-recs.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/different-loops-recs.ll?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/test/Analysis/ScalarEvolution/different-loops-recs.ll (original)
> +++ llvm/trunk/test/Analysis/ScalarEvolution/different-loops-recs.ll Mon Jul  2 13:01:54 2018
> @@ -322,7 +322,7 @@ define void @test_05(i32 %N) {
> ; CHECK:       %SQ = mul i32 %i.0, %i.0
> ; CHECK-NEXT:  -->  {4,+,5,+,2}<%bb3>
> ; CHECK:       %tmp4 = mul i32 %i.0, 2
> -; CHECK-NEXT:  -->  {4,+,2}<%bb3>
> +; CHECK-NEXT:  -->  {4,+,2}<nuw><nsw><%bb3>
> ; CHECK:       %tmp5 = sub i32 %SQ, %tmp4
> ; CHECK-NEXT:  -->  {0,+,3,+,2}<%bb3>
> 
> 
> Modified: llvm/trunk/test/Analysis/ScalarEvolution/extract-highbits-sameconstmask.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/extract-highbits-sameconstmask.ll?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/test/Analysis/ScalarEvolution/extract-highbits-sameconstmask.ll (original)
> +++ llvm/trunk/test/Analysis/ScalarEvolution/extract-highbits-sameconstmask.ll Mon Jul  2 13:01:54 2018
> @@ -8,7 +8,7 @@ define i32 @div(i32 %val) nounwind {
> ; CHECK-NEXT:    %tmp1 = udiv i32 %val, 16
> ; CHECK-NEXT:    -->  (%val /u 16) U: [0,268435456) S: [0,268435456)
> ; CHECK-NEXT:    %tmp2 = mul i32 %tmp1, 16
> -; CHECK-NEXT:    -->  (16 * (%val /u 16)) U: [0,-15) S: [0,-15)
> +; CHECK-NEXT:    -->  (16 * (%val /u 16))<nuw> U: [0,-15) S: [0,-15)
> ; CHECK-NEXT:  Determining loop execution counts for: @div
> ;
>   %tmp1 = udiv i32 %val, 16
> @@ -22,7 +22,7 @@ define i32 @sdiv(i32 %val) nounwind {
> ; CHECK-NEXT:    %tmp1 = sdiv i32 %val, 16
> ; CHECK-NEXT:    -->  %tmp1 U: full-set S: [-134217728,134217728)
> ; CHECK-NEXT:    %tmp2 = mul i32 %tmp1, 16
> -; CHECK-NEXT:    -->  (16 * %tmp1) U: [0,-15) S: [-2147483648,2147483633)
> +; CHECK-NEXT:    -->  (16 * %tmp1)<nsw> U: [0,-15) S: [-2147483648,2147483633)
> ; CHECK-NEXT:  Determining loop execution counts for: @sdiv
> ;
>   %tmp1 = sdiv i32 %val, 16
> @@ -38,7 +38,7 @@ define i32 @mask_b(i32 %val) nounwind {
> ; CHECK-LABEL: 'mask_b'
> ; CHECK-NEXT:  Classifying expressions for: @mask_b
> ; CHECK-NEXT:    %masked = and i32 %val, -16
> -; CHECK-NEXT:    -->  (16 * (%val /u 16)) U: [0,-15) S: [0,-15)
> +; CHECK-NEXT:    -->  (16 * (%val /u 16))<nuw> U: [0,-15) S: [0,-15)
> ; CHECK-NEXT:  Determining loop execution counts for: @mask_b
> ;
>   %masked = and i32 %val, -16
> @@ -51,7 +51,7 @@ define i32 @mask_d(i32 %val) nounwind {
> ; CHECK-NEXT:    %lowbitscleared = lshr i32 %val, 4
> ; CHECK-NEXT:    -->  (%val /u 16) U: [0,268435456) S: [0,268435456)
> ; CHECK-NEXT:    %masked = shl i32 %lowbitscleared, 4
> -; CHECK-NEXT:    -->  (16 * (%val /u 16)) U: [0,-15) S: [0,-15)
> +; CHECK-NEXT:    -->  (16 * (%val /u 16))<nuw> U: [0,-15) S: [0,-15)
> ; CHECK-NEXT:  Determining loop execution counts for: @mask_d
> ;
>   %lowbitscleared = lshr i32 %val, 4
> 
> Modified: llvm/trunk/test/Analysis/ScalarEvolution/lshr-shl-differentconstmask.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/lshr-shl-differentconstmask.ll?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/test/Analysis/ScalarEvolution/lshr-shl-differentconstmask.ll (original)
> +++ llvm/trunk/test/Analysis/ScalarEvolution/lshr-shl-differentconstmask.ll Mon Jul  2 13:01:54 2018
> @@ -8,7 +8,7 @@ define i32 @udiv_biggerLshr(i32 %val) no
> ; CHECK-NEXT:    %tmp1 = udiv i32 %val, 64
> ; CHECK-NEXT:    -->  (%val /u 64) U: [0,67108864) S: [0,67108864)
> ; CHECK-NEXT:    %tmp2 = mul i32 %tmp1, 16
> -; CHECK-NEXT:    -->  (16 * (%val /u 64)) U: [0,1073741809) S: [0,1073741809)
> +; CHECK-NEXT:    -->  (16 * (%val /u 64))<nuw><nsw> U: [0,1073741809) S: [0,1073741809)
> ; CHECK-NEXT:  Determining loop execution counts for: @udiv_biggerLshr
> ;
>   %tmp1 = udiv i32 %val, 64
> @@ -38,7 +38,7 @@ define i32 @shifty_biggerLshr(i32 %val)
> ; CHECK-NEXT:    %tmp1 = lshr i32 %val, 6
> ; CHECK-NEXT:    -->  (%val /u 64) U: [0,67108864) S: [0,67108864)
> ; CHECK-NEXT:    %tmp2 = shl i32 %tmp1, 4
> -; CHECK-NEXT:    -->  (16 * (%val /u 64)) U: [0,1073741809) S: [0,1073741809)
> +; CHECK-NEXT:    -->  (16 * (%val /u 64))<nuw><nsw> U: [0,1073741809) S: [0,1073741809)
> ; CHECK-NEXT:  Determining loop execution counts for: @shifty_biggerLshr
> ;
>   %tmp1 = lshr i32 %val, 6
> @@ -52,7 +52,7 @@ define i32 @shifty_biggerLshr_lshrexact(
> ; CHECK-NEXT:    %tmp1 = lshr exact i32 %val, 6
> ; CHECK-NEXT:    -->  (%val /u 64) U: [0,67108864) S: [0,67108864)
> ; CHECK-NEXT:    %tmp2 = shl i32 %tmp1, 4
> -; CHECK-NEXT:    -->  (16 * (%val /u 64)) U: [0,1073741809) S: [0,1073741809)
> +; CHECK-NEXT:    -->  (16 * (%val /u 64))<nuw><nsw> U: [0,1073741809) S: [0,1073741809)
> ; CHECK-NEXT:  Determining loop execution counts for: @shifty_biggerLshr_lshrexact
> ;
>   %tmp1 = lshr exact i32 %val, 6
> @@ -96,7 +96,7 @@ define i32 @masky_biggerLshr(i32 %val) {
> ; CHECK-NEXT:    %tmp1 = lshr i32 %val, 2
> ; CHECK-NEXT:    -->  (%val /u 4) U: [0,1073741824) S: [0,1073741824)
> ; CHECK-NEXT:    %tmp2 = and i32 %tmp1, -16
> -; CHECK-NEXT:    -->  (16 * (%val /u 64)) U: [0,1073741809) S: [0,1073741809)
> +; CHECK-NEXT:    -->  (16 * (%val /u 64))<nuw><nsw> U: [0,1073741809) S: [0,1073741809)
> ; CHECK-NEXT:  Determining loop execution counts for: @masky_biggerLshr
> ;
>   %tmp1 = lshr i32 %val, 2
> @@ -121,7 +121,7 @@ define i32 @masky_biggerShr(i32 %val) {
> ; CHECK-NEXT:    %tmp1 = shl i32 %val, 2
> ; CHECK-NEXT:    -->  (4 * %val) U: [0,-3) S: [-2147483648,2147483645)
> ; CHECK-NEXT:    %tmp2 = and i32 %tmp1, -64
> -; CHECK-NEXT:    -->  (64 * (zext i26 (trunc i32 (%val /u 16) to i26) to i32)) U: [0,-63) S: [0,-63)
> +; CHECK-NEXT:    -->  (64 * (zext i26 (trunc i32 (%val /u 16) to i26) to i32))<nuw> U: [0,-63) S: [0,-63)
> ; CHECK-NEXT:  Determining loop execution counts for: @masky_biggerShr
> ;
>   %tmp1 = shl i32 %val, 2
> 
> Modified: llvm/trunk/test/Analysis/ScalarEvolution/nsw-offset-assume.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/nsw-offset-assume.ll?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/test/Analysis/ScalarEvolution/nsw-offset-assume.ll (original)
> +++ llvm/trunk/test/Analysis/ScalarEvolution/nsw-offset-assume.ll Mon Jul  2 13:01:54 2018
> @@ -79,5 +79,5 @@ declare void @llvm.assume(i1) nounwind
> 
> ; Note: Without the preheader assume, there is an 'smax' in the
> ; backedge-taken count expression:
> -; CHECK: Loop %bb: backedge-taken count is ((-1 + (2 * (%no /u 2))) /u 2)
> +; CHECK: Loop %bb: backedge-taken count is ((-1 + (2 * (%no /u 2))<nuw>) /u 2)
> ; CHECK: Loop %bb: max backedge-taken count is 1073741822
> 
> Modified: llvm/trunk/test/Analysis/ScalarEvolution/nsw-offset.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/nsw-offset.ll?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/test/Analysis/ScalarEvolution/nsw-offset.ll (original)
> +++ llvm/trunk/test/Analysis/ScalarEvolution/nsw-offset.ll Mon Jul  2 13:01:54 2018
> @@ -73,5 +73,5 @@ return:
>   ret void
> }
> 
> -; CHECK: Loop %bb: backedge-taken count is ((-1 + (2 * (%no /u 2))) /u 2)
> +; CHECK: Loop %bb: backedge-taken count is ((-1 + (2 * (%no /u 2))<nuw>) /u 2)
> ; CHECK: Loop %bb: max backedge-taken count is 1073741822
> 
> Modified: llvm/trunk/test/Analysis/ScalarEvolution/nsw.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/nsw.ll?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/test/Analysis/ScalarEvolution/nsw.ll (original)
> +++ llvm/trunk/test/Analysis/ScalarEvolution/nsw.ll Mon Jul  2 13:01:54 2018
> @@ -126,7 +126,7 @@ exit:
> }
> 
> ; CHECK-LABEL: PR12375
> -; CHECK: -->  {(4 + %arg)<nsw>,+,4}<nuw><%bb1>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: (4 + (4 * ((-1 + (-1 * %arg) + ((4 + %arg)<nsw> umax (8 + %arg)<nsw>)) /u 4)) + %arg)
> +; CHECK: -->  {(4 + %arg)<nsw>,+,4}<nuw><%bb1>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: (4 + (4 * ((-1 + (-1 * %arg) + ((4 + %arg)<nsw> umax (8 + %arg)<nsw>)) /u 4))<nuw> + %arg)
> define i32 @PR12375(i32* readnone %arg) {
> bb:
>   %tmp = getelementptr inbounds i32, i32* %arg, i64 2
> @@ -145,7 +145,7 @@ bb7:
> }
> 
> ; CHECK-LABEL: PR12376
> -; CHECK: -->  {(4 + %arg)<nsw>,+,4}<nuw><%bb2>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: (4 + (4 * ((-1 + (-1 * %arg) + ((4 + %arg)<nsw> umax %arg1)) /u 4)) + %arg)
> +; CHECK: -->  {(4 + %arg)<nsw>,+,4}<nuw><%bb2>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: (4 + (4 * ((-1 + (-1 * %arg) + ((4 + %arg)<nsw> umax %arg1)) /u 4))<nuw> + %arg)
> define void @PR12376(i32* nocapture %arg, i32* nocapture %arg1)  {
> bb:
>   br label %bb2
> 
> Modified: llvm/trunk/test/Analysis/ScalarEvolution/predicated-trip-count.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/predicated-trip-count.ll?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/test/Analysis/ScalarEvolution/predicated-trip-count.ll (original)
> +++ llvm/trunk/test/Analysis/ScalarEvolution/predicated-trip-count.ll Mon Jul  2 13:01:54 2018
> @@ -80,7 +80,7 @@ return:         ; preds = %bb5
> ; CHECK-NEXT:    -->  (sext i16 {%Start,+,-1}<%bb3> to i32)
> ; CHECK:       Loop %bb3: Unpredictable backedge-taken count.
> ; CHECK-NEXT:  Loop %bb3: Unpredictable max backedge-taken count.
> -; CHECK-NEXT:  Loop %bb3: Predicated backedge-taken count is (2 + (sext i16 %Start to i32) + ((-2 + (-1 * (sext i16 %Start to i32))) smax (-1 + (-1 * %M))))
> +; CHECK-NEXT:  Loop %bb3: Predicated backedge-taken count is (2 + (sext i16 %Start to i32) + ((-2 + (-1 * (sext i16 %Start to i32))<nsw>) smax (-1 + (-1 * %M))))
> ; CHECK-NEXT:  Predicates:
> ; CHECK-NEXT:    {%Start,+,-1}<%bb3> Added Flags: <nssw>
> 
> 
> Modified: llvm/trunk/test/Analysis/ScalarEvolution/sext-mul.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/sext-mul.ll?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/test/Analysis/ScalarEvolution/sext-mul.ll (original)
> +++ llvm/trunk/test/Analysis/ScalarEvolution/sext-mul.ll Mon Jul  2 13:01:54 2018
> @@ -5,11 +5,11 @@
> ; CHECK: %tmp10 = ashr exact i64 %tmp9, 32
> ; CHECK-NEXT: --> {{.*}} Exits: (sext i32 (-2 + (2 * %arg2)) to i64)
> ; CHECK: %tmp11 = getelementptr inbounds i32, i32* %arg, i64 %tmp10
> -; CHECK-NEXT: --> {{.*}} Exits: ((4 * (sext i32 (-2 + (2 * %arg2)) to i64)) + %arg)
> +; CHECK-NEXT: --> {{.*}} Exits: ((4 * (sext i32 (-2 + (2 * %arg2)) to i64))<nsw> + %arg)
> ; CHECK:  %tmp14 = or i64 %tmp10, 1
> ; CHECK-NEXT: --> {{.*}} Exits: (1 + (sext i32 (-2 + (2 * %arg2)) to i64))<nsw>
> ; CHECK: %tmp15 = getelementptr inbounds i32, i32* %arg, i64 %tmp14
> -; CHECK-NEXT: --> {{.*}} Exits: (4 + (4 * (sext i32 (-2 + (2 * %arg2)) to i64)) + %arg)
> +; CHECK-NEXT: --> {{.*}} Exits: (4 + (4 * (sext i32 (-2 + (2 * %arg2)) to i64))<nsw> + %arg)
> ; CHECK:Loop %bb7: backedge-taken count is (-1 + (zext i32 %arg2 to i64))<nsw>
> ; CHECK-NEXT:Loop %bb7: max backedge-taken count is -1
> ; CHECK-NEXT:Loop %bb7: Predicated backedge-taken count is (-1 + (zext i32 %arg2 to i64))<nsw>
> 
> Modified: llvm/trunk/test/Analysis/ScalarEvolution/shl-lshr-differentconstmask.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/shl-lshr-differentconstmask.ll?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/test/Analysis/ScalarEvolution/shl-lshr-differentconstmask.ll (original)
> +++ llvm/trunk/test/Analysis/ScalarEvolution/shl-lshr-differentconstmask.ll Mon Jul  2 13:01:54 2018
> @@ -96,7 +96,7 @@ define i32 @masky_biggerShl(i32 %val) {
> ; CHECK-NEXT:    %tmp1 = shl i32 %val, 2
> ; CHECK-NEXT:    -->  (4 * %val) U: [0,-3) S: [-2147483648,2147483645)
> ; CHECK-NEXT:    %tmp2 = and i32 %tmp1, 268435452
> -; CHECK-NEXT:    -->  (4 * (zext i26 (trunc i32 %val to i26) to i32)) U: [0,268435453) S: [0,268435453)
> +; CHECK-NEXT:    -->  (4 * (zext i26 (trunc i32 %val to i26) to i32))<nuw><nsw> U: [0,268435453) S: [0,268435453)
> ; CHECK-NEXT:  Determining loop execution counts for: @masky_biggerShl
> ;
>   %tmp1 = shl i32 %val, 2
> 
> Modified: llvm/trunk/test/Analysis/ScalarEvolution/trip-count-pow2.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/trip-count-pow2.ll?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/test/Analysis/ScalarEvolution/trip-count-pow2.ll (original)
> +++ llvm/trunk/test/Analysis/ScalarEvolution/trip-count-pow2.ll Mon Jul  2 13:01:54 2018
> @@ -31,7 +31,7 @@ exit:
>   ret i32 %i
> 
> ; CHECK-LABEL: @test2
> -; CHECK: Loop %loop: backedge-taken count is ((-32 + (32 * (%n /u 32))) /u 32)
> +; CHECK: Loop %loop: backedge-taken count is ((-32 + (32 * (%n /u 32))<nuw>) /u 32)
> ; CHECK: Loop %loop: max backedge-taken count is 134217727
> }
> 
> 
> Modified: llvm/trunk/test/Analysis/ScalarEvolution/zext-mul.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/zext-mul.ll?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/test/Analysis/ScalarEvolution/zext-mul.ll (original)
> +++ llvm/trunk/test/Analysis/ScalarEvolution/zext-mul.ll Mon Jul  2 13:01:54 2018
> @@ -19,16 +19,20 @@ define void @no_range() {
> }
> 
> ; CHECK-LABEL: @range
> -;
> -; This had to be disabled when r334428 was reverted.  We should enable this test
> -; when r334428 is reapplied with a fix.
> define void @range() {
> -  %a = call i32 @get_int(), !range !0
> +  %a = call i32 @get_int(), !range !{i32 0, i32 100}
>   %b = mul i32 %a, 4
>   %c = zext i32 %b to i64
>   ; CHECK: %c
> -  ; CHECK-NEXT: --> (zext i32 (4 * %a) to i64)
> +  ; CHECK-NEXT: --> (4 * (zext i32 %a to i64))<nuw><nsw>
>   ret void
> }
> 
> -!0 = !{i32 0, i32 100}
> +; CHECK-LABEL: @no_nuw
> +define void @no_nuw() {
> +  %a = call i32 @get_int(), !range !{i32 0, i32 3}
> +  %b = mul i32 %a, -100
> +  ; CHECK: %b
> +  ; CHECK-NEXT: -->  (-100 * %a)<nsw>
> +  ret void
> +}
> 
> Modified: llvm/trunk/test/Transforms/LoopVersioning/incorrect-phi.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopVersioning/incorrect-phi.ll?rev=336140&r1=336139&r2=336140&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/LoopVersioning/incorrect-phi.ll (original)
> +++ llvm/trunk/test/Transforms/LoopVersioning/incorrect-phi.ll Mon Jul  2 13:01:54 2018
> @@ -14,18 +14,17 @@ bb6.lr.ph:
>   br label %bb6
> 
> bb6:                                              ; preds = %bb6.lr.ph, %bb6
> -  %_tmp1423 = phi i16 [ undef, %bb6.lr.ph ], [ %_tmp142, %bb6 ]
> +  %_tmp1423 = phi i64 [ undef, %bb6.lr.ph ], [ %_tmp142, %bb6 ]
>   %_tmp123 = getelementptr [2 x [3 x [5 x i16]]], [2 x [3 x [5 x i16]]]* @x, i16 0, i64 undef
> -  %_tmp125 = sext i16 %_tmp1423 to i64
> -  %_tmp126 = getelementptr [3 x [5 x i16]], [3 x [5 x i16]]* %_tmp123, i16 0, i64 %_tmp125
> +  %_tmp126 = getelementptr [3 x [5 x i16]], [3 x [5 x i16]]* %_tmp123, i16 0, i64 %_tmp1423
>   %_tmp129 = getelementptr [5 x i16], [5 x i16]* %_tmp126, i16 0, i64 undef
>   %_tmp130 = load i16, i16* %_tmp129
>   store i16 undef, i16* getelementptr ([2 x [3 x [5 x i16]]], [2 x [3 x [5 x i16]]]* @x, i64 0, i64 undef, i64 undef, i64 undef)
> -  %_tmp142 = add i16 %_tmp1423, 1
> +  %_tmp142 = add i64 %_tmp1423, 1
>   br i1 false, label %bb6, label %loop.exit
> 
> loop.exit:                                ; preds = %bb6
> -  %_tmp142.lcssa = phi i16 [ %_tmp142, %bb6 ]
> +  %_tmp142.lcssa = phi i64 [ %_tmp142, %bb6 ]
>   %split = phi i16 [ undef, %bb6 ]
> ; CHECK: %split = phi i16 [ undef, %bb6 ], [ undef, %bb6.lver.orig ]
>   br label %bb9
> @@ -41,18 +40,17 @@ bb6.lr.ph:
>   br label %bb6
> 
> bb6:                                              ; preds = %bb6.lr.ph, %bb6
> -  %_tmp1423 = phi i16 [ undef, %bb6.lr.ph ], [ %_tmp142, %bb6 ]
> +  %_tmp1423 = phi i64 [ undef, %bb6.lr.ph ], [ %_tmp142, %bb6 ]
>   %_tmp123 = getelementptr [2 x [3 x [5 x i16]]], [2 x [3 x [5 x i16]]]* @x, i16 0, i64 undef
> -  %_tmp125 = sext i16 %_tmp1423 to i64
> -  %_tmp126 = getelementptr [3 x [5 x i16]], [3 x [5 x i16]]* %_tmp123, i16 0, i64 %_tmp125
> +  %_tmp126 = getelementptr [3 x [5 x i16]], [3 x [5 x i16]]* %_tmp123, i16 0, i64 %_tmp1423
>   %_tmp129 = getelementptr [5 x i16], [5 x i16]* %_tmp126, i16 0, i64 undef
>   %_tmp130 = load i16, i16* %_tmp129
>   store i16 undef, i16* getelementptr ([2 x [3 x [5 x i16]]], [2 x [3 x [5 x i16]]]* @x, i64 0, i64 undef, i64 undef, i64 undef)
> -  %_tmp142 = add i16 %_tmp1423, 1
> +  %_tmp142 = add i64 %_tmp1423, 1
>   br i1 false, label %bb6, label %loop.exit
> 
> loop.exit:                                ; preds = %bb6
> -  %_tmp142.lcssa = phi i16 [ %_tmp142, %bb6 ]
> +  %_tmp142.lcssa = phi i64 [ %_tmp142, %bb6 ]
>   %split = phi i16 [ %t, %bb6 ]
> ; CHECK: %split = phi i16 [ %t, %bb6 ], [ %t, %bb6.lver.orig ]
>   br label %bb9
> 
> 
> _______________________________________________
> 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