Index: llvm/lib/Analysis/ValueTracking.cpp =================================================================== --- llvm/lib/Analysis/ValueTracking.cpp +++ llvm/lib/Analysis/ValueTracking.cpp @@ -84,13 +84,12 @@ // According to the LangRef, branching on a poison condition is absolutely // immediate full UB. However, historically we haven't implemented that -// consistently as we have an important transformation (non-trivial unswitch) +// consistently as we had an important transformation (non-trivial unswitch) // which introduces instances of branch on poison/undef to otherwise well -// defined programs. This flag exists to let us test optimization benefit -// of exploiting the specified behavior (in combination with enabling the -// unswitch fix.) +// defined programs. This issue has since been fixed, but the flag is +// temporarily retained to easily diagnose potential regressions. static cl::opt BranchOnPoisonAsUB("branch-on-poison-as-ub", - cl::Hidden, cl::init(false)); + cl::Hidden, cl::init(true)); /// Returns the bitwidth of the given scalar or pointer type. For vector types, Index: llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll =================================================================== --- llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll +++ llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll @@ -1099,7 +1099,7 @@ ; CHECK-NEXT: %ptr = getelementptr inbounds float, float* %input, i64 %index64 ; CHECK-NEXT: --> {((4 * (sext i32 (256 * %start) to i64)) + %input),+,1024}<%loop> U: full-set S: full-set Exits: ((4 * (sext i32 (256 * %start) to i64)) + (1024 * (zext i32 (-1 + (-1 * %start) + %numIterations) to i64)) + %input) LoopDispositions: { %loop: Computable } ; CHECK-NEXT: %nexti = add nsw i32 %i, 1 -; CHECK-NEXT: --> {(1 + %start),+,1}<%loop> U: full-set S: full-set Exits: %numIterations LoopDispositions: { %loop: Computable } +; CHECK-NEXT: --> {(1 + %start),+,1}<%loop> U: full-set S: full-set Exits: %numIterations LoopDispositions: { %loop: Computable } ; CHECK-NEXT: Determining loop execution counts for: @test-shl-nsw ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + (-1 * %start) + %numIterations) ; CHECK-NEXT: Loop %loop: max backedge-taken count is -1 @@ -1138,7 +1138,7 @@ ; CHECK-NEXT: %ptr = getelementptr inbounds float, float* %input, i64 %index64 ; CHECK-NEXT: --> ((4 * (sext i32 {(-2147483648 * %start),+,-2147483648}<%loop> to i64)) + %input) U: full-set S: full-set Exits: ((4 * (sext i32 (-2147483648 + (-2147483648 * %numIterations)) to i64)) + %input) LoopDispositions: { %loop: Computable } ; CHECK-NEXT: %nexti = add nsw i32 %i, 1 -; CHECK-NEXT: --> {(1 + %start),+,1}<%loop> U: full-set S: full-set Exits: %numIterations LoopDispositions: { %loop: Computable } +; CHECK-NEXT: --> {(1 + %start),+,1}<%loop> U: full-set S: full-set Exits: %numIterations LoopDispositions: { %loop: Computable } ; CHECK-NEXT: Determining loop execution counts for: @test-shl-nuw-edgecase ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + (-1 * %start) + %numIterations) ; CHECK-NEXT: Loop %loop: max backedge-taken count is -1 @@ -1177,7 +1177,7 @@ ; CHECK-NEXT: %ptr = getelementptr inbounds float, float* %input, i64 %index64 ; CHECK-NEXT: --> {((4 * (sext i32 (-2147483648 * %start) to i64)) + %input),+,-8589934592}<%loop> U: full-set S: full-set Exits: ((4 * (sext i32 (-2147483648 * %start) to i64)) + (-8589934592 * (zext i32 (-1 + (-1 * %start) + %numIterations) to i64)) + %input) LoopDispositions: { %loop: Computable } ; CHECK-NEXT: %nexti = add nsw i32 %i, 1 -; CHECK-NEXT: --> {(1 + %start),+,1}<%loop> U: full-set S: full-set Exits: %numIterations LoopDispositions: { %loop: Computable } +; CHECK-NEXT: --> {(1 + %start),+,1}<%loop> U: full-set S: full-set Exits: %numIterations LoopDispositions: { %loop: Computable } ; CHECK-NEXT: Determining loop execution counts for: @test-shl-nuw-nsw ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + (-1 * %start) + %numIterations) ; CHECK-NEXT: Loop %loop: max backedge-taken count is -1 @@ -1216,7 +1216,7 @@ ; CHECK-NEXT: %ptr = getelementptr inbounds float, float* %input, i64 %index64 ; CHECK-NEXT: --> ((4 * (sext i32 {(-2147483648 * %start),+,-2147483648}<%loop> to i64)) + %input) U: full-set S: full-set Exits: ((4 * (sext i32 (-2147483648 + (-2147483648 * %numIterations)) to i64)) + %input) LoopDispositions: { %loop: Computable } ; CHECK-NEXT: %nexti = add nsw i32 %i, 1 -; CHECK-NEXT: --> {(1 + %start),+,1}<%loop> U: full-set S: full-set Exits: %numIterations LoopDispositions: { %loop: Computable } +; CHECK-NEXT: --> {(1 + %start),+,1}<%loop> U: full-set S: full-set Exits: %numIterations LoopDispositions: { %loop: Computable } ; CHECK-NEXT: Determining loop execution counts for: @test-shl-no-nsw ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + (-1 * %start) + %numIterations) ; CHECK-NEXT: Loop %loop: max backedge-taken count is -1 @@ -1255,7 +1255,7 @@ ; CHECK-NEXT: %ptr = getelementptr inbounds float, float* %input, i64 %index64 ; CHECK-NEXT: --> {((4 * (sext i32 (1073741824 * %start) to i64)) + %input),+,4294967296}<%loop> U: full-set S: full-set Exits: ((4 * (sext i32 (1073741824 * %start) to i64)) + (4294967296 * (zext i32 (-1 + (-1 * %start) + %numIterations) to i64)) + %input) LoopDispositions: { %loop: Computable } ; CHECK-NEXT: %nexti = add nsw i32 %i, 1 -; CHECK-NEXT: --> {(1 + %start),+,1}<%loop> U: full-set S: full-set Exits: %numIterations LoopDispositions: { %loop: Computable } +; CHECK-NEXT: --> {(1 + %start),+,1}<%loop> U: full-set S: full-set Exits: %numIterations LoopDispositions: { %loop: Computable } ; CHECK-NEXT: Determining loop execution counts for: @test-shl-nsw-edgecase ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + (-1 * %start) + %numIterations) ; CHECK-NEXT: Loop %loop: max backedge-taken count is -1 @@ -1332,7 +1332,7 @@ ; CHECK-NEXT: %ptr = getelementptr inbounds float, float* %input, i64 %index64 ; CHECK-NEXT: --> {((4 * (sext i32 %start to i64)) + (-4 * (sext i32 %sub to i64)) + %input),+,4}<%loop> U: full-set S: full-set Exits: ((4 * (zext i32 (-1 + (-1 * %start) + %numIterations) to i64)) + (4 * (sext i32 %start to i64)) + (-4 * (sext i32 %sub to i64)) + %input) LoopDispositions: { %loop: Computable } ; CHECK-NEXT: %nexti = add nsw i32 %i, 1 -; CHECK-NEXT: --> {(1 + %start),+,1}<%loop> U: full-set S: full-set Exits: %numIterations LoopDispositions: { %loop: Computable } +; CHECK-NEXT: --> {(1 + %start),+,1}<%loop> U: full-set S: full-set Exits: %numIterations LoopDispositions: { %loop: Computable } ; CHECK-NEXT: Determining loop execution counts for: @test-sub-no-nsw ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + (-1 * %start) + %numIterations) ; CHECK-NEXT: Loop %loop: max backedge-taken count is -1 @@ -1373,7 +1373,7 @@ ; CHECK-NEXT: %ptr = getelementptr inbounds float, float* %input, i64 %index64 ; CHECK-NEXT: --> {((4 * (sext i32 %start to i64)) + (-4 * (sext i32 %halfsub to i64)) + %input),+,4}<%loop> U: full-set S: full-set Exits: ((4 * (zext i32 (-1 + (-1 * %start) + %numIterations) to i64)) + (4 * (sext i32 %start to i64)) + (-4 * (sext i32 %halfsub to i64)) + %input) LoopDispositions: { %loop: Computable } ; CHECK-NEXT: %nexti = add nsw i32 %i, 1 -; CHECK-NEXT: --> {(1 + %start),+,1}<%loop> U: full-set S: full-set Exits: %numIterations LoopDispositions: { %loop: Computable } +; CHECK-NEXT: --> {(1 + %start),+,1}<%loop> U: full-set S: full-set Exits: %numIterations LoopDispositions: { %loop: Computable } ; CHECK-NEXT: Determining loop execution counts for: @test-sub-nsw ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + (-1 * %start) + %numIterations) ; CHECK-NEXT: Loop %loop: max backedge-taken count is -1 Index: llvm/test/Analysis/ScalarEvolution/limit-depth.ll =================================================================== --- llvm/test/Analysis/ScalarEvolution/limit-depth.ll +++ llvm/test/Analysis/ScalarEvolution/limit-depth.ll @@ -59,7 +59,7 @@ define void @test_sext(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f) { ; CHECK-LABEL: @test_sext ; CHECK: %se2 = sext i64 %iv2.inc to i128 -; CHECK-NEXT: --> {(1 + (sext i64 {(sext i32 (1 + %a) to i64),+,1}<%loop> to i128)),+,1}<%loop2> +; CHECK-NEXT: --> {(1 + (sext i64 {(sext i32 (1 + %a) to i64),+,1}<%loop> to i128)),+,1}<%loop2> entry: br label %loop Index: llvm/test/Analysis/ScalarEvolution/no-wrap-symbolic-becount.ll =================================================================== --- llvm/test/Analysis/ScalarEvolution/no-wrap-symbolic-becount.ll +++ llvm/test/Analysis/ScalarEvolution/no-wrap-symbolic-becount.ll @@ -123,9 +123,9 @@ ; CHECK-LABEL: 'pointer_iv_nowrap_guard' ; CHECK-NEXT: Classifying expressions for: @pointer_iv_nowrap_guard ; CHECK-NEXT: %init = getelementptr inbounds i32, i32* %startptr, i64 2000 -; CHECK-NEXT: --> (8000 + %startptr) U: full-set S: full-set +; CHECK-NEXT: --> (8000 + %startptr) U: [8000,0) S: [8000,0) ; CHECK-NEXT: %iv = phi i32* [ %init, %entry ], [ %iv.next, %loop ] -; CHECK-NEXT: --> {(8000 + %startptr),+,4}<%loop> U: full-set S: full-set Exits: (8000 + (4 * ((-8001 + (-1 * (ptrtoint i32* %startptr to i64)) + ((8004 + (ptrtoint i32* %startptr to i64)) umax (ptrtoint i32* %endptr to i64))) /u 4)) + %startptr) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: --> {(8000 + %startptr),+,4}<%loop> U: [8000,0) S: [8000,0) Exits: (8000 + (4 * ((-8001 + (-1 * (ptrtoint i32* %startptr to i64)) + ((8004 + (ptrtoint i32* %startptr to i64)) umax (ptrtoint i32* %endptr to i64))) /u 4)) + %startptr) LoopDispositions: { %loop: Computable } ; CHECK-NEXT: %iv.next = getelementptr inbounds i32, i32* %iv, i64 1 ; CHECK-NEXT: --> {(8004 + %startptr),+,4}<%loop> U: full-set S: full-set Exits: (8004 + (4 * ((-8001 + (-1 * (ptrtoint i32* %startptr to i64)) + ((8004 + (ptrtoint i32* %startptr to i64)) umax (ptrtoint i32* %endptr to i64))) /u 4)) + %startptr) LoopDispositions: { %loop: Computable } ; CHECK-NEXT: Determining loop execution counts for: @pointer_iv_nowrap_guard Index: llvm/test/Analysis/ScalarEvolution/nsw.ll =================================================================== --- llvm/test/Analysis/ScalarEvolution/nsw.ll +++ llvm/test/Analysis/ScalarEvolution/nsw.ll @@ -107,17 +107,19 @@ ; CHECK-LABEL: 'test3' ; CHECK-NEXT: Classifying expressions for: @test3 ; CHECK-NEXT: %indvar.i.i = phi i64 [ %tmp, %for.body.i.i ], [ 0, %entry ] -; CHECK-NEXT: --> {0,+,1}<%for.body.i.i> U: [0,-9223372036854775808) S: [0,-9223372036854775808) Exits: <> LoopDispositions: { %for.body.i.i: Computable } +; CHECK-NEXT: --> {0,+,1}<%for.body.i.i> U: [0,4611686018427387904) S: [0,4611686018427387904) Exits: ((-4 + (-1 * (ptrtoint i32* %begin to i64)) + (ptrtoint i32* %end to i64)) /u 4) LoopDispositions: { %for.body.i.i: Computable } ; CHECK-NEXT: %tmp = add nsw i64 %indvar.i.i, 1 -; CHECK-NEXT: --> {1,+,1}<%for.body.i.i> U: [1,-9223372036854775808) S: [1,-9223372036854775808) Exits: <> LoopDispositions: { %for.body.i.i: Computable } +; CHECK-NEXT: --> {1,+,1}<%for.body.i.i> U: [1,4611686018427387905) S: [1,4611686018427387905) Exits: (1 + ((-4 + (-1 * (ptrtoint i32* %begin to i64)) + (ptrtoint i32* %end to i64)) /u 4)) LoopDispositions: { %for.body.i.i: Computable } ; CHECK-NEXT: %ptrincdec.i.i = getelementptr inbounds i32, i32* %begin, i64 %tmp -; CHECK-NEXT: --> {(4 + %begin),+,4}<%for.body.i.i> U: full-set S: full-set Exits: <> LoopDispositions: { %for.body.i.i: Computable } +; CHECK-NEXT: --> {(4 + %begin),+,4}<%for.body.i.i> U: full-set S: full-set Exits: (4 + (4 * ((-4 + (-1 * (ptrtoint i32* %begin to i64)) + (ptrtoint i32* %end to i64)) /u 4)) + %begin) LoopDispositions: { %for.body.i.i: Computable } ; CHECK-NEXT: %__first.addr.08.i.i = getelementptr inbounds i32, i32* %begin, i64 %indvar.i.i -; CHECK-NEXT: --> {%begin,+,4}<%for.body.i.i> U: full-set S: full-set Exits: <> LoopDispositions: { %for.body.i.i: Computable } +; CHECK-NEXT: --> {%begin,+,4}<%for.body.i.i> U: full-set S: full-set Exits: ((4 * ((-4 + (-1 * (ptrtoint i32* %begin to i64)) + (ptrtoint i32* %end to i64)) /u 4)) + %begin) LoopDispositions: { %for.body.i.i: Computable } ; CHECK-NEXT: Determining loop execution counts for: @test3 -; CHECK-NEXT: Loop %for.body.i.i: Unpredictable backedge-taken count. -; CHECK-NEXT: Loop %for.body.i.i: Unpredictable max backedge-taken count. -; CHECK-NEXT: Loop %for.body.i.i: Unpredictable predicated backedge-taken count. +; CHECK-NEXT: Loop %for.body.i.i: backedge-taken count is ((-4 + (-1 * (ptrtoint i32* %begin to i64)) + (ptrtoint i32* %end to i64)) /u 4) +; CHECK-NEXT: Loop %for.body.i.i: max backedge-taken count is 4611686018427387903 +; CHECK-NEXT: Loop %for.body.i.i: Predicated backedge-taken count is ((-4 + (-1 * (ptrtoint i32* %begin to i64)) + (ptrtoint i32* %end to i64)) /u 4) +; CHECK-NEXT: Predicates: +; CHECK: Loop %for.body.i.i: Trip multiple is 1 ; entry: %cmp7.i.i = icmp eq i32* %begin, %end @@ -165,21 +167,21 @@ ; CHECK-LABEL: 'PR12375' ; CHECK-NEXT: Classifying expressions for: @PR12375 ; CHECK-NEXT: %tmp = getelementptr inbounds i32, i32* %arg, i64 2 -; CHECK-NEXT: --> (8 + %arg) U: full-set S: full-set +; CHECK-NEXT: --> (8 + %arg) U: [8,0) S: [8,0) ; CHECK-NEXT: %tmp2 = phi i32* [ %arg, %bb ], [ %tmp5, %bb1 ] -; CHECK-NEXT: --> {%arg,+,4}<%bb1> U: full-set S: full-set Exits: ((4 * ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (8 + (ptrtoint i32* %arg to i64)))) /u 4)) + %arg) LoopDispositions: { %bb1: Computable } +; CHECK-NEXT: --> {%arg,+,4}<%bb1> U: full-set S: full-set Exits: (4 + %arg) LoopDispositions: { %bb1: Computable } ; CHECK-NEXT: %tmp3 = phi i32 [ 0, %bb ], [ %tmp4, %bb1 ] -; CHECK-NEXT: --> {0,+,1}<%bb1> U: [0,-2147483648) S: [0,-2147483648) Exits: (trunc i64 ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (8 + (ptrtoint i32* %arg to i64)))) /u 4) to i32) LoopDispositions: { %bb1: Computable } +; CHECK-NEXT: --> {0,+,1}<%bb1> U: [0,-2147483648) S: [0,-2147483648) Exits: 1 LoopDispositions: { %bb1: Computable } ; CHECK-NEXT: %tmp4 = add nsw i32 %tmp3, 1 -; CHECK-NEXT: --> {1,+,1}<%bb1> U: [1,0) S: [1,0) Exits: (1 + (trunc i64 ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (8 + (ptrtoint i32* %arg to i64)))) /u 4) to i32)) LoopDispositions: { %bb1: Computable } +; CHECK-NEXT: --> {1,+,1}<%bb1> U: [1,0) S: [1,0) Exits: 2 LoopDispositions: { %bb1: Computable } ; CHECK-NEXT: %tmp5 = getelementptr inbounds i32, i32* %tmp2, i64 1 -; CHECK-NEXT: --> {(4 + %arg),+,4}<%bb1> U: full-set S: full-set Exits: (4 + (4 * ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (8 + (ptrtoint i32* %arg to i64)))) /u 4)) + %arg) LoopDispositions: { %bb1: Computable } +; CHECK-NEXT: --> {(4 + %arg),+,4}<%bb1> U: [4,0) S: [4,0) Exits: (8 + %arg) LoopDispositions: { %bb1: Computable } ; CHECK-NEXT: Determining loop execution counts for: @PR12375 -; CHECK-NEXT: Loop %bb1: backedge-taken count is ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (8 + (ptrtoint i32* %arg to i64)))) /u 4) -; CHECK-NEXT: Loop %bb1: max backedge-taken count is 1, actual taken count either this or zero. -; CHECK-NEXT: Loop %bb1: Predicated backedge-taken count is ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (8 + (ptrtoint i32* %arg to i64)))) /u 4) +; CHECK-NEXT: Loop %bb1: backedge-taken count is 1 +; CHECK-NEXT: Loop %bb1: max backedge-taken count is 1 +; CHECK-NEXT: Loop %bb1: Predicated backedge-taken count is 1 ; CHECK-NEXT: Predicates: -; CHECK: Loop %bb1: Trip multiple is 1 +; CHECK: Loop %bb1: Trip multiple is 2 ; bb: %tmp = getelementptr inbounds i32, i32* %arg, i64 2 @@ -201,13 +203,13 @@ ; CHECK-LABEL: 'PR12376' ; CHECK-NEXT: Classifying expressions for: @PR12376 ; CHECK-NEXT: %tmp = phi i32* [ %arg, %bb ], [ %tmp4, %bb2 ] -; CHECK-NEXT: --> {%arg,+,4}<%bb2> U: full-set S: full-set Exits: ((4 * ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (ptrtoint i32* %arg1 to i64))) /u 4)) + %arg) LoopDispositions: { %bb2: Computable } +; CHECK-NEXT: --> {%arg,+,4}<%bb2> U: full-set S: full-set Exits: ((4 * ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (ptrtoint i32* %arg1 to i64))) /u 4)) + %arg) LoopDispositions: { %bb2: Computable } ; CHECK-NEXT: %tmp4 = getelementptr inbounds i32, i32* %tmp, i64 1 -; CHECK-NEXT: --> {(4 + %arg),+,4}<%bb2> U: full-set S: full-set Exits: (4 + (4 * ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (ptrtoint i32* %arg1 to i64))) /u 4)) + %arg) LoopDispositions: { %bb2: Computable } +; CHECK-NEXT: --> {(4 + %arg),+,4}<%bb2> U: [4,0) S: [4,0) Exits: (4 + (4 * ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (ptrtoint i32* %arg1 to i64))) /u 4)) + %arg) LoopDispositions: { %bb2: Computable } ; CHECK-NEXT: Determining loop execution counts for: @PR12376 -; CHECK-NEXT: Loop %bb2: backedge-taken count is ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (ptrtoint i32* %arg1 to i64))) /u 4) -; CHECK-NEXT: Loop %bb2: max backedge-taken count is 4611686018427387903 -; CHECK-NEXT: Loop %bb2: Predicated backedge-taken count is ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (ptrtoint i32* %arg1 to i64))) /u 4) +; CHECK-NEXT: Loop %bb2: backedge-taken count is ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (ptrtoint i32* %arg1 to i64))) /u 4) +; CHECK-NEXT: Loop %bb2: max backedge-taken count is 4611686018427387902 +; CHECK-NEXT: Loop %bb2: Predicated backedge-taken count is ((-1 + (-1 * (ptrtoint i32* %arg to i64)) + ((4 + (ptrtoint i32* %arg to i64)) umax (ptrtoint i32* %arg1 to i64))) /u 4) ; CHECK-NEXT: Predicates: ; CHECK: Loop %bb2: Trip multiple is 1 ; @@ -270,21 +272,21 @@ ; CHECK-NEXT: %array = alloca [10 x i32], align 4 ; CHECK-NEXT: --> %array U: [0,-3) S: [-9223372036854775808,9223372036854775805) ; CHECK-NEXT: %index = phi i32 [ %inc5, %for.body ], [ %arg, %entry ] -; CHECK-NEXT: --> {%arg,+,1}<%for.body> U: full-set S: full-set Exits: (-1 + (10 smax (1 + %arg))) LoopDispositions: { %for.body: Computable } +; CHECK-NEXT: --> {%arg,+,1}<%for.body> U: full-set S: full-set Exits: (-1 + (10 smax (1 + %arg))) LoopDispositions: { %for.body: Computable } ; CHECK-NEXT: %sub = add nsw i32 %index, -2 -; CHECK-NEXT: --> {(-2 + %arg),+,1}<%for.body> U: full-set S: full-set Exits: (-3 + (10 smax (1 + %arg))) LoopDispositions: { %for.body: Computable } +; CHECK-NEXT: --> {(-2 + %arg),+,1}<%for.body> U: full-set S: full-set Exits: (-3 + (10 smax (1 + %arg))) LoopDispositions: { %for.body: Computable } ; CHECK-NEXT: %idxprom = sext i32 %sub to i64 -; CHECK-NEXT: --> {(-2 + (sext i32 %arg to i64)),+,1}<%for.body> U: [-2147483650,4294967304) S: [-2147483650,4294967304) Exits: (-2 + (zext i32 (-1 + (-1 * %arg) + (10 smax (1 + %arg))) to i64) + (sext i32 %arg to i64)) LoopDispositions: { %for.body: Computable } +; CHECK-NEXT: --> {(-2 + (sext i32 %arg to i64)),+,1}<%for.body> U: [-2147483650,4294967304) S: [-2147483650,4294967304) Exits: (-2 + (zext i32 (-1 + (-1 * %arg) + (10 smax (1 + %arg))) to i64) + (sext i32 %arg to i64)) LoopDispositions: { %for.body: Computable } ; CHECK-NEXT: %arrayidx = getelementptr inbounds [10 x i32], [10 x i32]* %array, i64 0, i64 %idxprom -; CHECK-NEXT: --> {(-8 + (4 * (sext i32 %arg to i64)) + %array),+,4}<%for.body> U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: (-8 + (4 * (zext i32 (-1 + (-1 * %arg) + (10 smax (1 + %arg))) to i64)) + (4 * (sext i32 %arg to i64)) + %array) LoopDispositions: { %for.body: Computable } +; CHECK-NEXT: --> {(-8 + (4 * (sext i32 %arg to i64)) + %array),+,4}<%for.body> U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: (-8 + (4 * (zext i32 (-1 + (-1 * %arg) + (10 smax (1 + %arg))) to i64)) + (4 * (sext i32 %arg to i64)) + %array) LoopDispositions: { %for.body: Computable } ; CHECK-NEXT: %data = load i32, i32* %arrayidx, align 4 ; CHECK-NEXT: --> %data U: full-set S: full-set Exits: <> LoopDispositions: { %for.body: Variant } ; CHECK-NEXT: %inc5 = add nsw i32 %index, 1 -; CHECK-NEXT: --> {(1 + %arg),+,1}<%for.body> U: full-set S: full-set Exits: (10 smax (1 + %arg)) LoopDispositions: { %for.body: Computable } +; CHECK-NEXT: --> {(1 + %arg),+,1}<%for.body> U: full-set S: full-set Exits: (10 smax (1 + %arg)) LoopDispositions: { %for.body: Computable } ; CHECK-NEXT: Determining loop execution counts for: @test4 -; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + (-1 * %arg) + (10 smax (1 + %arg))) +; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + (-1 * %arg) + (10 smax (1 + %arg))) ; CHECK-NEXT: Loop %for.body: max backedge-taken count is -2147483638 -; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + (-1 * %arg) + (10 smax (1 + %arg))) +; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + (-1 * %arg) + (10 smax (1 + %arg))) ; CHECK-NEXT: Predicates: ; CHECK: Loop %for.body: Trip multiple is 1 ; Index: llvm/test/Analysis/ScalarEvolution/trip-count-negative-stride.ll =================================================================== --- llvm/test/Analysis/ScalarEvolution/trip-count-negative-stride.ll +++ llvm/test/Analysis/ScalarEvolution/trip-count-negative-stride.ll @@ -102,9 +102,9 @@ define void @ult_129_unknown_start(i8 %start) mustprogress { ; CHECK-LABEL: 'ult_129_unknown_start' ; CHECK-NEXT: Determining loop execution counts for: @ult_129_unknown_start -; CHECK-NEXT: Loop %for.body: backedge-taken count is (((127 + (-1 * (1 umin (127 + (-1 * %start) + (-128 umax (-127 + %start))))) + (-1 * %start) + (-128 umax (-127 + %start))) /u -127) + (1 umin (127 + (-1 * %start) + (-128 umax (-127 + %start))))) -; CHECK-NEXT: Loop %for.body: max backedge-taken count is 1 -; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (((127 + (-1 * (1 umin (127 + (-1 * %start) + (-128 umax (-127 + %start))))) + (-1 * %start) + (-128 umax (-127 + %start))) /u -127) + (1 umin (127 + (-1 * %start) + (-128 umax (-127 + %start))))) +; CHECK-NEXT: Loop %for.body: backedge-taken count is 0 +; CHECK-NEXT: Loop %for.body: max backedge-taken count is 0 +; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is 0 ; CHECK-NEXT: Predicates: ; CHECK: Loop %for.body: Trip multiple is 1 ; Index: llvm/test/Analysis/ScalarEvolution/trip-count-non-unit-stride.ll =================================================================== --- llvm/test/Analysis/ScalarEvolution/trip-count-non-unit-stride.ll +++ llvm/test/Analysis/ScalarEvolution/trip-count-non-unit-stride.ll @@ -171,7 +171,7 @@ ; CHECK-NEXT: %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ] ; CHECK-NEXT: --> {0,+,-2}<%loop> U: [0,-1) S: [-9223372036854775808,1) Exits: <> LoopDispositions: { %loop: Computable } ; CHECK-NEXT: %iv.inc = add nsw i64 %iv, -1 -; CHECK-NEXT: --> {-1,+,-2}<%loop> U: full-set S: full-set Exits: <> LoopDispositions: { %loop: Computable } +; CHECK-NEXT: --> {-1,+,-2}<%loop> U: [-9223372036854775808,0) S: [-9223372036854775808,0) Exits: <> LoopDispositions: { %loop: Computable } ; CHECK-NEXT: %iv.inc2 = add nsw i64 %iv, -2 ; CHECK-NEXT: --> {-2,+,-2}<%loop> U: [0,-1) S: [-9223372036854775808,9223372036854775807) Exits: <> LoopDispositions: { %loop: Computable } ; CHECK-NEXT: Determining loop execution counts for: @test_postinc_sgt Index: llvm/test/Transforms/AggressiveInstCombine/funnel.ll =================================================================== --- llvm/test/Transforms/AggressiveInstCombine/funnel.ll +++ llvm/test/Transforms/AggressiveInstCombine/funnel.ll @@ -385,9 +385,8 @@ ; CHECK: fshbb: ; CHECK-NEXT: br label [[END]] ; CHECK: end: -; CHECK-NEXT: [[TMP0:%.*]] = freeze i32 [[C]] -; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.fshr.i32(i32 [[TMP0]], i32 [[B:%.*]], i32 [[C]]) -; CHECK-NEXT: ret i32 [[TMP1]] +; CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.fshr.i32(i32 [[C]], i32 [[B:%.*]], i32 [[C]]) +; CHECK-NEXT: ret i32 [[TMP0]] ; entry: %cmp = icmp eq i32 %c, 0 Index: llvm/test/Transforms/AggressiveInstCombine/rotate.ll =================================================================== --- llvm/test/Transforms/AggressiveInstCombine/rotate.ll +++ llvm/test/Transforms/AggressiveInstCombine/rotate.ll @@ -380,9 +380,8 @@ ; CHECK: rotbb: ; CHECK-NEXT: br label [[END]] ; CHECK: end: -; CHECK-NEXT: [[TMP0:%.*]] = freeze i32 [[B]] -; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.fshr.i32(i32 [[TMP0]], i32 [[A:%.*]], i32 [[B]]) -; CHECK-NEXT: ret i32 [[TMP1]] +; CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.fshr.i32(i32 [[B]], i32 [[A:%.*]], i32 [[B]]) +; CHECK-NEXT: ret i32 [[TMP0]] ; entry: %cmp = icmp eq i32 %b, 0 Index: llvm/test/Transforms/IndVarSimplify/ashr-expansion.ll =================================================================== --- llvm/test/Transforms/IndVarSimplify/ashr-expansion.ll +++ llvm/test/Transforms/IndVarSimplify/ashr-expansion.ll @@ -6,7 +6,7 @@ define float @ashr_expansion_valid(i64 %x, float* %ptr) { ; CHECK-LABEL: @ashr_expansion_valid( ; CHECK-NEXT: entry: -; CHECK-NEXT: [[BOUND:%.*]] = ashr i64 [[X:%.*]], 4 +; CHECK-NEXT: [[BOUND:%.*]] = ashr exact i64 [[X:%.*]], 4 ; CHECK-NEXT: [[UMAX:%.*]] = call i64 @llvm.umax.i64(i64 [[BOUND]], i64 1) ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: @@ -49,7 +49,7 @@ ; CHECK-NEXT: [[DIV:%.*]] = udiv exact i64 [[ABS_X]], 16 ; CHECK-NEXT: [[T0:%.*]] = call i64 @llvm.smax.i64(i64 [[X]], i64 -1) ; CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.smin.i64(i64 [[T0]], i64 1) -; CHECK-NEXT: [[BOUND:%.*]] = mul i64 [[DIV]], [[T1]] +; CHECK-NEXT: [[BOUND:%.*]] = mul nsw i64 [[DIV]], [[T1]] ; CHECK-NEXT: [[UMAX:%.*]] = call i64 @llvm.umax.i64(i64 [[BOUND]], i64 1) ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: @@ -97,7 +97,7 @@ ; CHECK-NEXT: [[DIV:%.*]] = udiv i64 [[ABS_X]], 16 ; CHECK-NEXT: [[T0:%.*]] = call i64 @llvm.smax.i64(i64 [[X]], i64 -1) ; CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.smin.i64(i64 [[T0]], i64 1) -; CHECK-NEXT: [[BOUND:%.*]] = mul i64 [[DIV]], [[T1]] +; CHECK-NEXT: [[BOUND:%.*]] = mul nsw i64 [[DIV]], [[T1]] ; CHECK-NEXT: [[UMAX:%.*]] = call i64 @llvm.umax.i64(i64 [[BOUND]], i64 1) ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: @@ -145,7 +145,7 @@ ; CHECK-NEXT: [[DIV:%.*]] = udiv i64 [[ABS_X]], 16 ; CHECK-NEXT: [[T0:%.*]] = call i64 @llvm.smax.i64(i64 [[Y:%.*]], i64 -1) ; CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.smin.i64(i64 [[T0]], i64 1) -; CHECK-NEXT: [[BOUND:%.*]] = mul i64 [[DIV]], [[T1]] +; CHECK-NEXT: [[BOUND:%.*]] = mul nsw i64 [[DIV]], [[T1]] ; CHECK-NEXT: [[UMAX:%.*]] = call i64 @llvm.umax.i64(i64 [[BOUND]], i64 1) ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: Index: llvm/test/Transforms/IndVarSimplify/lftr-address-space-pointers.ll =================================================================== --- llvm/test/Transforms/IndVarSimplify/lftr-address-space-pointers.ll +++ llvm/test/Transforms/IndVarSimplify/lftr-address-space-pointers.ll @@ -7,7 +7,7 @@ ; CHECK-LABEL: @ptriv_as2( ; CHECK-NEXT: entry: ; CHECK-NEXT: [[IDX_TRUNC:%.*]] = trunc i32 [[N:%.*]] to i8 -; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr i8, i8 addrspace(2)* [[BASE:%.*]], i8 [[IDX_TRUNC]] +; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, i8 addrspace(2)* [[BASE:%.*]], i8 [[IDX_TRUNC]] ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i8 addrspace(2)* [[BASE]], [[ADD_PTR]] ; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_END:%.*]] ; CHECK: for.body.preheader: @@ -53,7 +53,7 @@ ; CHECK-LABEL: @ptriv_as3( ; CHECK-NEXT: entry: ; CHECK-NEXT: [[IDX_TRUNC:%.*]] = trunc i32 [[N:%.*]] to i16 -; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr i8, i8 addrspace(3)* [[BASE:%.*]], i16 [[IDX_TRUNC]] +; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, i8 addrspace(3)* [[BASE:%.*]], i16 [[IDX_TRUNC]] ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i8 addrspace(3)* [[BASE]], [[ADD_PTR]] ; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_END:%.*]] ; CHECK: for.body.preheader: Index: llvm/test/Transforms/IndVarSimplify/lftr-reuse.ll =================================================================== --- llvm/test/Transforms/IndVarSimplify/lftr-reuse.ll +++ llvm/test/Transforms/IndVarSimplify/lftr-reuse.ll @@ -16,7 +16,7 @@ ; CHECK-LABEL: @ptriv( ; CHECK-NEXT: entry: ; CHECK-NEXT: [[IDX_EXT:%.*]] = sext i32 [[N:%.*]] to i64 -; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr i8, i8* [[BASE:%.*]], i64 [[IDX_EXT]] +; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, i8* [[BASE:%.*]], i64 [[IDX_EXT]] ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i8* [[BASE]], [[ADD_PTR]] ; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_END:%.*]] ; CHECK: for.body.preheader: @@ -63,7 +63,7 @@ define void @expandOuterRecurrence(i32 %arg) nounwind { ; CHECK-LABEL: @expandOuterRecurrence( ; CHECK-NEXT: entry: -; CHECK-NEXT: [[SUB1:%.*]] = sub i32 [[ARG:%.*]], 1 +; CHECK-NEXT: [[SUB1:%.*]] = sub nsw i32 [[ARG:%.*]], 1 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 0, [[SUB1]] ; CHECK-NEXT: br i1 [[CMP1]], label [[OUTER_PREHEADER:%.*]], label [[EXIT:%.*]] ; CHECK: outer.preheader: Index: llvm/test/Transforms/IndVarSimplify/pr24783.ll =================================================================== --- llvm/test/Transforms/IndVarSimplify/pr24783.ll +++ llvm/test/Transforms/IndVarSimplify/pr24783.ll @@ -7,7 +7,7 @@ define void @f(i32* %end.s, i8** %loc, i32 %p) { ; CHECK-LABEL: @f( ; CHECK-NEXT: entry: -; CHECK-NEXT: [[END:%.*]] = getelementptr i32, i32* [[END_S:%.*]], i32 [[P:%.*]] +; CHECK-NEXT: [[END:%.*]] = getelementptr inbounds i32, i32* [[END_S:%.*]], i32 [[P:%.*]] ; CHECK-NEXT: br label [[WHILE_BODY_I:%.*]] ; CHECK: while.body.i: ; CHECK-NEXT: br i1 true, label [[LOOP_EXIT:%.*]], label [[WHILE_BODY_I]] Index: llvm/test/Transforms/LoopStrengthReduce/X86/expander-crashes.ll =================================================================== --- llvm/test/Transforms/LoopStrengthReduce/X86/expander-crashes.ll +++ llvm/test/Transforms/LoopStrengthReduce/X86/expander-crashes.ll @@ -17,7 +17,7 @@ ; CHECK-NEXT: [[LSR_IV5:%.*]] = phi i64 [ [[LSR_IV_NEXT6:%.*]], [[LOOP_1_HEADER]] ], [ [[START1]], [[ENTRY:%.*]] ] ; CHECK-NEXT: [[IV:%.*]] = phi %struct.hoge* [ [[IV_NEXT:%.*]], [[LOOP_1_HEADER]] ], [ [[START]], [[ENTRY]] ] ; CHECK-NEXT: [[IV_NEXT]] = getelementptr inbounds [[STRUCT_HOGE:%.*]], %struct.hoge* [[IV]], i64 1 -; CHECK-NEXT: [[LSR_IV_NEXT6]] = add i64 [[LSR_IV5]], 16 +; CHECK-NEXT: [[LSR_IV_NEXT6]] = add nuw i64 [[LSR_IV5]], 16 ; CHECK-NEXT: [[EC:%.*]] = icmp eq %struct.hoge* [[IV_NEXT]], [[END:%.*]] ; CHECK-NEXT: br i1 [[EC]], label [[LOOP_2_PH:%.*]], label [[LOOP_1_HEADER]] ; CHECK: loop.2.ph: Index: llvm/test/Transforms/LoopVectorize/AArch64/scalable-avoid-scalarization.ll =================================================================== --- llvm/test/Transforms/LoopVectorize/AArch64/scalable-avoid-scalarization.ll +++ llvm/test/Transforms/LoopVectorize/AArch64/scalable-avoid-scalarization.ll @@ -11,7 +11,7 @@ define void @test_no_scalarization(i64* %a, i32 %idx, i32 %n) #0 { ; CHECK-LABEL: @test_no_scalarization( ; CHECK-NEXT: L.entry: -; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[IDX:%.*]], 1 +; CHECK-NEXT: [[TMP0:%.*]] = add nsw i32 [[IDX:%.*]], 1 ; CHECK-NEXT: [[SMAX:%.*]] = call i32 @llvm.smax.i32(i32 [[N:%.*]], i32 [[TMP0]]) ; CHECK-NEXT: [[TMP1:%.*]] = sub i32 [[SMAX]], [[IDX]] ; CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.vscale.i32() Index: llvm/test/Transforms/VectorCombine/AArch64/load-extractelement-scalarization.ll =================================================================== --- llvm/test/Transforms/VectorCombine/AArch64/load-extractelement-scalarization.ll +++ llvm/test/Transforms/VectorCombine/AArch64/load-extractelement-scalarization.ll @@ -683,16 +683,11 @@ ; CHECK-LABEL: @load_extract_safe_with_freeze( ; CHECK-NEXT: entry: ; CHECK-NEXT: [[EXT_IDX:%.*]] = extractelement <8 x i8> [[IN:%.*]], i32 0 -; CHECK-NEXT: [[EXT_IDX_I32:%.*]] = zext i8 [[EXT_IDX]] to i32 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[EXT_IDX]], 99 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[EXIT:%.*]] ; CHECK: then: -; CHECK-NEXT: [[LOAD:%.*]] = load <16 x i8>, <16 x i8>* [[SRC:%.*]], align 16 -; CHECK-NEXT: [[AND:%.*]] = and i32 [[EXT_IDX_I32]], 15 -; CHECK-NEXT: [[EXT:%.*]] = extractelement <16 x i8> [[LOAD]], i32 [[AND]] ; CHECK-NEXT: br label [[EXIT]] ; CHECK: exit: -; CHECK-NEXT: [[P:%.*]] = phi i8 [ 0, [[ENTRY:%.*]] ], [ [[EXT]], [[THEN]] ] ; CHECK-NEXT: ret i8 0 ; entry: