diff options
Diffstat (limited to 'llvm/test/Analysis')
| -rw-r--r-- | llvm/test/Analysis/ScalarEvolution/nsw.ll | 4 | ||||
| -rw-r--r-- | llvm/test/Analysis/ScalarEvolution/trip-count13.ll | 81 |
2 files changed, 83 insertions, 2 deletions
diff --git a/llvm/test/Analysis/ScalarEvolution/nsw.ll b/llvm/test/Analysis/ScalarEvolution/nsw.ll index 49050c53d06..a3752919d33 100644 --- a/llvm/test/Analysis/ScalarEvolution/nsw.ll +++ b/llvm/test/Analysis/ScalarEvolution/nsw.ll @@ -126,7 +126,7 @@ exit: } ; CHECK-LABEL: PR12375 -; CHECK: --> {(4 + %arg)<nsw>,+,4}<nuw><%bb1>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: (8 + %arg)<nsw> +; 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) define i32 @PR12375(i32* readnone %arg) { bb: %tmp = getelementptr inbounds i32, i32* %arg, i64 2 @@ -163,7 +163,7 @@ bb5: ; preds = %bb2 declare void @f(i32) ; CHECK-LABEL: nswnowrap -; CHECK: --> {(1 + %v)<nsw>,+,1}<nsw><%for.body>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: (2 + %v) +; CHECK: --> {(1 + %v)<nsw>,+,1}<nsw><%for.body>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: (1 + ((1 + %v)<nsw> smax %v)) define void @nswnowrap(i32 %v, i32* %buf) { entry: %add = add nsw i32 %v, 1 diff --git a/llvm/test/Analysis/ScalarEvolution/trip-count13.ll b/llvm/test/Analysis/ScalarEvolution/trip-count13.ll new file mode 100644 index 00000000000..37ef2fd500a --- /dev/null +++ b/llvm/test/Analysis/ScalarEvolution/trip-count13.ll @@ -0,0 +1,81 @@ +; RUN: opt -S -analyze -scalar-evolution < %s | FileCheck %s + +define void @u_0(i8 %rhs) { +; E.g.: %rhs = 255, %start = 99, backedge taken 156 times +entry: + %start = add i8 %rhs, 100 + br label %loop + +loop: + %iv = phi i8 [ %start, %entry ], [ %iv.inc, %loop ] + %iv.inc = add nuw i8 %iv, 1 ;; Note: this never unsigned-wraps + %iv.cmp = icmp ult i8 %iv, %rhs + br i1 %iv.cmp, label %loop, label %leave + +; CHECK-LABEL: Determining loop execution counts for: @u_0 +; CHECK-NEXT: Loop %loop: backedge-taken count is (-100 + (-1 * %rhs) + ((100 + %rhs) umax %rhs)) +; CHECK-NEXT: Loop %loop: max backedge-taken count is -1 + +leave: + ret void +} + +define void @u_1(i8 %start) { +entry: +; E.g.: %start = 99, %rhs = 255, backedge taken 156 times + %rhs = add i8 %start, -100 + br label %loop + +loop: + %iv = phi i8 [ %start, %entry ], [ %iv.inc, %loop ] + %iv.inc = add nuw i8 %iv, 1 ;; Note: this never unsigned-wraps + %iv.cmp = icmp ult i8 %iv, %rhs + br i1 %iv.cmp, label %loop, label %leave + +; CHECK-LABEL: Determining loop execution counts for: @u_1 +; CHECK-NEXT: Loop %loop: backedge-taken count is ((-1 * %start) + ((-100 + %start) umax %start)) +; CHECK-NEXT: Loop %loop: max backedge-taken count is -1 + +leave: + ret void +} + +define void @s_0(i8 %rhs) { +entry: +; E.g.: %rhs = 127, %start = -29, backedge taken 156 times + %start = add i8 %rhs, 100 + br label %loop + +loop: + %iv = phi i8 [ %start, %entry ], [ %iv.inc, %loop ] + %iv.inc = add nsw i8 %iv, 1 ;; Note: this never signed-wraps + %iv.cmp = icmp slt i8 %iv, %rhs + br i1 %iv.cmp, label %loop, label %leave + +; CHECK-LABEL: Determining loop execution counts for: @s_0 +; CHECK-NEXT: Loop %loop: backedge-taken count is (-100 + (-1 * %rhs) + ((100 + %rhs) smax %rhs)) +; CHECK-NEXT: Loop %loop: max backedge-taken count is -1 + +leave: + ret void +} + +define void @s_1(i8 %start) { +entry: +; E.g.: start = -29, %rhs = 127, %backedge taken 156 times + %rhs = add i8 %start, -100 + br label %loop + +loop: + %iv = phi i8 [ %start, %entry ], [ %iv.inc, %loop ] + %iv.inc = add nsw i8 %iv, 1 + %iv.cmp = icmp slt i8 %iv, %rhs + br i1 %iv.cmp, label %loop, label %leave + +; CHECK-LABEL: Determining loop execution counts for: @s_1 +; CHECK-NEXT: Loop %loop: backedge-taken count is ((-1 * %start) + ((-100 + %start) smax %start)) +; CHECK-NEXT: Loop %loop: max backedge-taken count is -1 + +leave: + ret void +} |

