From 336291e777f3e74bea2ae16f7bf61b8f4a76c869 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Tue, 14 Sep 2021 14:48:47 -0700 Subject: [PATCH] autogen a test for ease of update in later patch --- llvm/test/Analysis/ScalarEvolution/nsw.ll | 272 ++++++++++++++++------ 1 file changed, 202 insertions(+), 70 deletions(-) diff --git a/llvm/test/Analysis/ScalarEvolution/nsw.ll b/llvm/test/Analysis/ScalarEvolution/nsw.ll index f8ef5ca5cbdd..bdcddbeffd3e 100644 --- a/llvm/test/Analysis/ScalarEvolution/nsw.ll +++ b/llvm/test/Analysis/ScalarEvolution/nsw.ll @@ -1,59 +1,86 @@ +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py ; RUN: opt < %s -disable-output "-passes=print" 2>&1 | FileCheck %s ; The addrecs in this loop are analyzable only by using nsw information. target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" -; CHECK: Classifying expressions for: @test1 define void @test1(double* %p) nounwind { +; CHECK-LABEL: 'test1' +; CHECK-NEXT: Classifying expressions for: @test1 +; CHECK-NEXT: %i.01 = phi i32 [ %tmp8, %bb1 ], [ 0, %bb.nph ] +; CHECK-NEXT: --> {0,+,1}<%bb> U: [0,-2147483648) S: [0,-2147483648) Exits: <> LoopDispositions: { %bb: Computable } +; CHECK-NEXT: %tmp2 = sext i32 %i.01 to i64 +; CHECK-NEXT: --> {0,+,1}<%bb> U: [0,-9223372036854775808) S: [0,-9223372036854775808) Exits: <> LoopDispositions: { %bb: Computable } +; CHECK-NEXT: %tmp3 = getelementptr double, double* %p, i64 %tmp2 +; CHECK-NEXT: --> {%p,+,8}<%bb> U: full-set S: full-set Exits: <> LoopDispositions: { %bb: Computable } +; CHECK-NEXT: %tmp6 = sext i32 %i.01 to i64 +; CHECK-NEXT: --> {0,+,1}<%bb> U: [0,-9223372036854775808) S: [0,-9223372036854775808) Exits: <> LoopDispositions: { %bb: Computable } +; CHECK-NEXT: %tmp7 = getelementptr double, double* %p, i64 %tmp6 +; CHECK-NEXT: --> {%p,+,8}<%bb> U: full-set S: full-set Exits: <> LoopDispositions: { %bb: Computable } +; CHECK-NEXT: %tmp8 = add nsw i32 %i.01, 1 +; CHECK-NEXT: --> {1,+,1}<%bb> U: [1,-2147483648) S: [1,-2147483648) Exits: <> LoopDispositions: { %bb: Computable } +; CHECK-NEXT: %p.gep = getelementptr double, double* %p, i32 %tmp8 +; CHECK-NEXT: --> {(8 + %p),+,8}<%bb> U: full-set S: full-set Exits: <> LoopDispositions: { %bb: Computable } +; CHECK-NEXT: %phitmp = sext i32 %tmp8 to i64 +; CHECK-NEXT: --> {1,+,1}<%bb> U: [1,-9223372036854775808) S: [1,-9223372036854775808) Exits: <> LoopDispositions: { %bb: Computable } +; CHECK-NEXT: %tmp9 = getelementptr inbounds double, double* %p, i64 %phitmp +; CHECK-NEXT: --> {(8 + %p),+,8}<%bb> U: [8,0) S: [8,0) Exits: <> LoopDispositions: { %bb: Computable } +; CHECK-NEXT: Determining loop execution counts for: @test1 +; CHECK-NEXT: Loop %bb: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %bb: Unpredictable max backedge-taken count. +; CHECK-NEXT: Loop %bb: Unpredictable predicated backedge-taken count. +; entry: - %tmp = load double, double* %p, align 8 ; [#uses=1] - %tmp1 = fcmp ogt double %tmp, 2.000000e+00 ; [#uses=1] - br i1 %tmp1, label %bb.nph, label %return + %tmp = load double, double* %p, align 8 ; [#uses=1] + %tmp1 = fcmp ogt double %tmp, 2.000000e+00 ; [#uses=1] + br i1 %tmp1, label %bb.nph, label %return bb.nph: ; preds = %entry - br label %bb + br label %bb bb: ; preds = %bb1, %bb.nph - %i.01 = phi i32 [ %tmp8, %bb1 ], [ 0, %bb.nph ] ; [#uses=3] -; CHECK: %i.01 -; CHECK-NEXT: --> {0,+,1}<%bb> - %tmp2 = sext i32 %i.01 to i64 ; [#uses=1] - %tmp3 = getelementptr double, double* %p, i64 %tmp2 ; [#uses=1] - %tmp4 = load double, double* %tmp3, align 8 ; [#uses=1] - %tmp5 = fmul double %tmp4, 9.200000e+00 ; [#uses=1] - %tmp6 = sext i32 %i.01 to i64 ; [#uses=1] - %tmp7 = getelementptr double, double* %p, i64 %tmp6 ; [#uses=1] -; CHECK: %tmp7 -; CHECK-NEXT: --> {%p,+,8}<%bb> - store double %tmp5, double* %tmp7, align 8 - %tmp8 = add nsw i32 %i.01, 1 ; [#uses=2] -; CHECK: %tmp8 -; CHECK-NEXT: --> {1,+,1}<%bb> - %p.gep = getelementptr double, double* %p, i32 %tmp8 - %p.val = load double, double* %p.gep - br label %bb1 + %i.01 = phi i32 [ %tmp8, %bb1 ], [ 0, %bb.nph ] ; [#uses=3] + %tmp2 = sext i32 %i.01 to i64 ; [#uses=1] + %tmp3 = getelementptr double, double* %p, i64 %tmp2 ; [#uses=1] + %tmp4 = load double, double* %tmp3, align 8 ; [#uses=1] + %tmp5 = fmul double %tmp4, 9.200000e+00 ; [#uses=1] + %tmp6 = sext i32 %i.01 to i64 ; [#uses=1] + %tmp7 = getelementptr double, double* %p, i64 %tmp6 ; [#uses=1] + store double %tmp5, double* %tmp7, align 8 + %tmp8 = add nsw i32 %i.01, 1 ; [#uses=2] + %p.gep = getelementptr double, double* %p, i32 %tmp8 + %p.val = load double, double* %p.gep + br label %bb1 bb1: ; preds = %bb - %phitmp = sext i32 %tmp8 to i64 ; [#uses=1] -; CHECK: %phitmp -; CHECK-NEXT: --> {1,+,1}<%bb> - %tmp9 = getelementptr inbounds double, double* %p, i64 %phitmp ; [#uses=1] -; CHECK: %tmp9 -; CHECK-NEXT: --> {(8 + %p),+,8}<%bb> - %tmp10 = load double, double* %tmp9, align 8 ; [#uses=1] - %tmp11 = fcmp ogt double %tmp10, 2.000000e+00 ; [#uses=1] - br i1 %tmp11, label %bb, label %bb1.return_crit_edge + %phitmp = sext i32 %tmp8 to i64 ; [#uses=1] + %tmp9 = getelementptr inbounds double, double* %p, i64 %phitmp ; [#uses=1] + %tmp10 = load double, double* %tmp9, align 8 ; [#uses=1] + %tmp11 = fcmp ogt double %tmp10, 2.000000e+00 ; [#uses=1] + br i1 %tmp11, label %bb, label %bb1.return_crit_edge bb1.return_crit_edge: ; preds = %bb1 - br label %return + br label %return return: ; preds = %bb1.return_crit_edge, %entry - ret void + ret void } -; CHECK: Classifying expressions for: @test2 define void @test2(i32* %begin, i32* %end) ssp { +; CHECK-LABEL: 'test2' +; CHECK-NEXT: Classifying expressions for: @test2 +; CHECK-NEXT: %__first.addr.02.i.i = phi i32* [ %begin, %for.body.lr.ph.i.i ], [ %ptrincdec.i.i, %for.body.i.i ] +; 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: %ptrincdec.i.i = getelementptr inbounds i32, i32* %__first.addr.02.i.i, i64 1 +; CHECK-NEXT: --> {(4 + %begin),+,4}<%for.body.i.i> U: [4,0) S: [4,0) 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: Determining loop execution counts for: @test2 +; 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: %cmp1.i.i = icmp eq i32* %begin, %end br i1 %cmp1.i.i, label %_ZSt4fillIPiiEvT_S1_RKT0_.exit, label %for.body.lr.ph.i.i @@ -63,12 +90,8 @@ for.body.lr.ph.i.i: ; preds = %entry for.body.i.i: ; preds = %for.body.i.i, %for.body.lr.ph.i.i %__first.addr.02.i.i = phi i32* [ %begin, %for.body.lr.ph.i.i ], [ %ptrincdec.i.i, %for.body.i.i ] -; CHECK: %__first.addr.02.i.i -; CHECK-NEXT: --> {%begin,+,4}<%for.body.i.i> store i32 0, i32* %__first.addr.02.i.i, align 4 %ptrincdec.i.i = getelementptr inbounds i32, i32* %__first.addr.02.i.i, i64 1 -; CHECK: %ptrincdec.i.i -; CHECK-NEXT: --> {(4 + %begin),+,4}<%for.body.i.i> %cmp.i.i = icmp eq i32* %ptrincdec.i.i, %end br i1 %cmp.i.i, label %for.cond.for.end_crit_edge.i.i, label %for.body.i.i @@ -81,36 +104,51 @@ _ZSt4fillIPiiEvT_S1_RKT0_.exit: ; preds = %entry, %for.cond.fo ; Various checks for inbounds geps. define void @test3(i32* %begin, i32* %end) nounwind ssp { +; 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,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,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: [4,0) S: [4,0) 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: ((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: 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 br i1 %cmp7.i.i, label %_ZSt4fillIPiiEvT_S1_RKT0_.exit, label %for.body.i.i for.body.i.i: ; preds = %entry, %for.body.i.i %indvar.i.i = phi i64 [ %tmp, %for.body.i.i ], [ 0, %entry ] -; CHECK: %indvar.i.i -; CHECK: {0,+,1}<%for.body.i.i> %tmp = add nsw i64 %indvar.i.i, 1 -; CHECK: %tmp = -; CHECK: {1,+,1}<%for.body.i.i> %ptrincdec.i.i = getelementptr inbounds i32, i32* %begin, i64 %tmp -; CHECK: %ptrincdec.i.i = -; CHECK: {(4 + %begin),+,4}<%for.body.i.i> %__first.addr.08.i.i = getelementptr inbounds i32, i32* %begin, i64 %indvar.i.i -; CHECK: %__first.addr.08.i.i -; CHECK: {%begin,+,4}<%for.body.i.i> store i32 0, i32* %__first.addr.08.i.i, align 4 %cmp.i.i = icmp eq i32* %ptrincdec.i.i, %end br i1 %cmp.i.i, label %_ZSt4fillIPiiEvT_S1_RKT0_.exit, label %for.body.i.i -; CHECK: Loop %for.body.i.i: backedge-taken count is ((-4 + (-1 * (ptrtoint i32* %begin to i64)) + (ptrtoint i32* %end to i64)) /u 4) -; CHECK: Loop %for.body.i.i: max backedge-taken count is 4611686018427387903 _ZSt4fillIPiiEvT_S1_RKT0_.exit: ; preds = %for.body.i.i, %entry ret void } ; A single AddExpr exists for (%a + %b), which is not always . -; CHECK: @addnsw -; CHECK-NOT: --> (%a + %b) define i32 @addnsw(i32 %a, i32 %b) nounwind ssp { +; CHECK-LABEL: 'addnsw' +; CHECK-NEXT: Classifying expressions for: @addnsw +; CHECK-NEXT: %tmp = add i32 %a, %b +; CHECK-NEXT: --> (%a + %b) U: full-set S: full-set +; CHECK-NEXT: %tmp2 = add nsw i32 %a, %b +; CHECK-NEXT: --> (%a + %b) U: full-set S: full-set +; CHECK-NEXT: %result = phi i32 [ %a, %entry ], [ %tmp2, %greater ] +; CHECK-NEXT: --> %result U: full-set S: full-set +; CHECK-NEXT: Determining loop execution counts for: @addnsw +; entry: %tmp = add i32 %a, %b %cmp = icmp sgt i32 %tmp, 0 @@ -125,10 +163,26 @@ exit: ret i32 %result } -; CHECK-LABEL: PR12375 -; CHECK: --> {(4 + %arg),+,4}<%bb1>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: (8 + %arg) - define i32 @PR12375(i32* readnone %arg) { +; CHECK-LABEL: 'PR12375' +; CHECK-NEXT: Classifying expressions for: @PR12375 +; CHECK-NEXT: %tmp = getelementptr inbounds i32, i32* %arg, i64 2 +; 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 + %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: 1 LoopDispositions: { %bb1: Computable } +; CHECK-NEXT: %tmp4 = add nsw i32 %tmp3, 1 +; 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: [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 +; 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 2 +; bb: %tmp = getelementptr inbounds i32, i32* %arg, i64 2 br label %bb1 @@ -145,9 +199,20 @@ bb7: ; preds = %bb1 ret i32 %tmp4 } -; CHECK-LABEL: PR12376 -; CHECK: --> {(4 + %arg),+,4}<%bb2>{{ U: [^ ]+ S: [^ ]+}}{{ *}}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) define void @PR12376(i32* nocapture %arg, i32* nocapture %arg1) { +; 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: %tmp4 = getelementptr inbounds i32, i32* %tmp, i64 1 +; 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 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 +; bb: br label %bb2 @@ -163,9 +228,26 @@ bb5: ; preds = %bb2 declare void @f(i32) -; CHECK-LABEL: nswnowrap -; CHECK: --> {(1 + %v),+,1}<%for.body>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: (1 + ((1 + %v) smax %v)) define void @nswnowrap(i32 %v, i32* %buf) { +; CHECK-LABEL: 'nswnowrap' +; CHECK-NEXT: Classifying expressions for: @nswnowrap +; CHECK-NEXT: %add = add nsw i32 %v, 1 +; CHECK-NEXT: --> (1 + %v) U: full-set S: full-set +; CHECK-NEXT: %i.04 = phi i32 [ %v, %entry ], [ %inc, %for.body ] +; CHECK-NEXT: --> {%v,+,1}<%for.body> U: full-set S: full-set Exits: ((1 + %v) smax %v) LoopDispositions: { %for.body: Computable } +; CHECK-NEXT: %inc = add nsw i32 %i.04, 1 +; CHECK-NEXT: --> {(1 + %v),+,1}<%for.body> U: full-set S: full-set Exits: (1 + ((1 + %v) smax %v)) LoopDispositions: { %for.body: Computable } +; CHECK-NEXT: %buf.gep = getelementptr inbounds i32, i32* %buf, i32 %inc +; CHECK-NEXT: --> {(4 + (4 * (sext i32 %v to i64)) + %buf),+,4}<%for.body> U: full-set S: full-set Exits: (4 + (4 * (zext i32 ((-1 * %v) + ((1 + %v) smax %v)) to i64)) + (4 * (sext i32 %v to i64)) + %buf) LoopDispositions: { %for.body: Computable } +; CHECK-NEXT: %buf.val = load i32, i32* %buf.gep, align 4 +; CHECK-NEXT: --> %buf.val U: full-set S: full-set Exits: <> LoopDispositions: { %for.body: Variant } +; CHECK-NEXT: Determining loop execution counts for: @nswnowrap +; CHECK-NEXT: Loop %for.body: backedge-taken count is ((-1 * %v) + ((1 + %v) smax %v)) +; CHECK-NEXT: Loop %for.body: max backedge-taken count is 1, actual taken count either this or zero. +; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is ((-1 * %v) + ((1 + %v) smax %v)) +; CHECK-NEXT: Predicates: +; CHECK: Loop %for.body: Trip multiple is 1 +; entry: %add = add nsw i32 %v, 1 br label %for.body @@ -184,10 +266,30 @@ for.end: } ; This test checks if no-wrap flags are propagated when folding {S,+,X}+T ==> {S+T,+,X} -; CHECK-LABEL: test4 -; CHECK: %idxprom -; CHECK-NEXT: --> {(-2 + (sext i32 %arg to i64)),+,1}<%for.body> define void @test4(i32 %arg) { +; CHECK-LABEL: 'test4' +; CHECK-NEXT: Classifying expressions for: @test4 +; 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: %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: %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: %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: %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: 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: 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: Predicates: +; CHECK: Loop %for.body: Trip multiple is 1 +; entry: %array = alloca [10 x i32], align 4 br label %for.body @@ -208,15 +310,25 @@ for.end: define void @bad_postinc_nsw_a(i32 %n) { -; CHECK-LABEL: Classifying expressions for: @bad_postinc_nsw_a +; CHECK-LABEL: 'bad_postinc_nsw_a' +; CHECK-NEXT: Classifying expressions for: @bad_postinc_nsw_a +; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ] +; CHECK-NEXT: --> {0,+,7}<%loop> U: [0,-2147483648) S: [0,-2147483648) Exits: (7 * ((((-1 * (1 umin %n)) + %n) /u 7) + (1 umin %n))) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.inc = add nsw i32 %iv, 7 +; CHECK-NEXT: --> {7,+,7}<%loop> U: [7,0) S: [7,0) Exits: (7 + (7 * ((((-1 * (1 umin %n)) + %n) /u 7) + (1 umin %n)))) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: Determining loop execution counts for: @bad_postinc_nsw_a +; CHECK-NEXT: Loop %loop: backedge-taken count is ((((-1 * (1 umin %n)) + %n) /u 7) + (1 umin %n)) +; CHECK-NEXT: Loop %loop: max backedge-taken count is 613566756 +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((((-1 * (1 umin %n)) + %n) /u 7) + (1 umin %n)) +; CHECK-NEXT: Predicates: +; CHECK: Loop %loop: Trip multiple is 1 +; entry: br label %loop loop: %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ] %iv.inc = add nsw i32 %iv, 7 -; CHECK: %iv.inc = add nsw i32 %iv, 7 -; CHECK-NEXT: --> {7,+,7}<%loop> %becond = icmp ult i32 %iv, %n br i1 %becond, label %loop, label %leave @@ -227,7 +339,19 @@ leave: ; Unlike @bad_postinc_nsw_a(), the SCEV expression of %iv.inc has flag ; because poison can be propagated through 'and %iv.inc, 0'. define void @postinc_poison_prop_through_and(i32 %n) { -; CHECK-LABEL: Classifying expressions for: @postinc_poison_prop_through_and +; CHECK-LABEL: 'postinc_poison_prop_through_and' +; CHECK-NEXT: Classifying expressions for: @postinc_poison_prop_through_and +; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ] +; CHECK-NEXT: --> {0,+,7}<%loop> U: [0,-2147483648) S: [0,-2147483648) Exits: <> LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.inc = add nsw i32 %iv, 7 +; CHECK-NEXT: --> {7,+,7}<%loop> U: [7,-2147483648) S: [7,-2147483648) Exits: <> LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.inc.and = and i32 %iv.inc, 0 +; CHECK-NEXT: --> 0 U: [0,1) S: [0,1) Exits: 0 LoopDispositions: { %loop: Invariant } +; CHECK-NEXT: Determining loop execution counts for: @postinc_poison_prop_through_and +; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable max backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count. +; entry: br label %loop @@ -235,8 +359,6 @@ loop: %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ] %iv.inc = add nsw i32 %iv, 7 %iv.inc.and = and i32 %iv.inc, 0 -; CHECK: %iv.inc = add nsw i32 %iv, 7 -; CHECK-NEXT: --> {7,+,7}<%loop> %becond = icmp ult i32 %iv.inc.and, %n br i1 %becond, label %loop, label %leave @@ -247,15 +369,25 @@ leave: declare void @may_exit() nounwind define void @pr28012(i32 %n) { -; CHECK-LABEL: Classifying expressions for: @pr28012 +; CHECK-LABEL: 'pr28012' +; CHECK-NEXT: Classifying expressions for: @pr28012 +; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ] +; CHECK-NEXT: --> {0,+,7}<%loop> U: [0,-2147483648) S: [0,-2147483648) Exits: (7 * ((-1 + (7 umax %n)) /u 7)) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.inc = add nsw i32 %iv, 7 +; CHECK-NEXT: --> {7,+,7}<%loop> U: [7,-3) S: [7,-3) Exits: (7 + (7 * ((-1 + (7 umax %n)) /u 7))) LoopDispositions: { %loop: Computable } +; CHECK-NEXT: Determining loop execution counts for: @pr28012 +; CHECK-NEXT: Loop %loop: backedge-taken count is ((-1 + (7 umax %n)) /u 7) +; CHECK-NEXT: Loop %loop: max backedge-taken count is 613566755 +; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((-1 + (7 umax %n)) /u 7) +; CHECK-NEXT: Predicates: +; CHECK: Loop %loop: Trip multiple is 1 +; entry: br label %loop loop: %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ] %iv.inc = add nsw i32 %iv, 7 -; CHECK: %iv.inc = add nsw i32 %iv, 7 -; CHECK-NEXT: --> {7,+,7}<%loop> %becond = icmp ult i32 %iv.inc, %n call void @may_exit() br i1 %becond, label %loop, label %leave -- GitLab