diff options
| author | Artur Pilipenko <apilipenko@azulsystems.com> | 2016-10-19 19:43:54 +0000 |
|---|---|---|
| committer | Artur Pilipenko <apilipenko@azulsystems.com> | 2016-10-19 19:43:54 +0000 |
| commit | 5c6ef754851b891ecfc685e9f1394d98569b5c8b (patch) | |
| tree | 0b89392c78ad35e28aacd2c40161cfeeee87a4d7 /llvm/test | |
| parent | 41fa838f07c2cc456b16addb1703c0203e372047 (diff) | |
| download | bcm5719-llvm-5c6ef754851b891ecfc685e9f1394d98569b5c8b.tar.gz bcm5719-llvm-5c6ef754851b891ecfc685e9f1394d98569b5c8b.zip | |
[IndVarSimplify] Teach calculatePostIncRange to take guards into account
Reviewed By: sanjoy
Differential Revision: https://reviews.llvm.org/D25739
llvm-svn: 284632
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/IndVarSimplify/post-inc-range.ll | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/llvm/test/Transforms/IndVarSimplify/post-inc-range.ll b/llvm/test/Transforms/IndVarSimplify/post-inc-range.ll index 717f0611a74..d859eb28e78 100644 --- a/llvm/test/Transforms/IndVarSimplify/post-inc-range.ll +++ b/llvm/test/Transforms/IndVarSimplify/post-inc-range.ll @@ -173,3 +173,117 @@ for.end: exit: ret void } + +declare void @llvm.experimental.guard(i1, ...) + +define void @test_guard_one_bb(i32* %base, i32 %limit, i32 %start) { +; CHECK-LABEL: @test_guard_one_bb( +; CHECK-NOT: trunc +; CHECK-NOT: icmp slt i32 + +for.body.lr.ph: + br label %for.body + +for.body: + %i = phi i32 [ %start, %for.body.lr.ph ], [ %i.inc, %for.body ] + %within_limits = icmp ult i32 %i, 64 + %i.i64 = zext i32 %i to i64 + %arrayidx = getelementptr inbounds i32, i32* %base, i64 %i.i64 + %val = load i32, i32* %arrayidx, align 4 + call void(i1, ...) @llvm.experimental.guard(i1 %within_limits) [ "deopt"() ] + %i.inc = add nsw nuw i32 %i, 1 + %cmp = icmp slt i32 %i.inc, %limit + br i1 %cmp, label %for.body, label %for.end + +for.end: + br label %exit + +exit: + ret void +} + +define void @test_guard_in_the_same_bb(i32* %base, i32 %limit, i32 %start) { +; CHECK-LABEL: @test_guard_in_the_same_bb( +; CHECK-NOT: trunc +; CHECK-NOT: icmp slt i32 + +for.body.lr.ph: + br label %for.body + +for.body: + %i = phi i32 [ %start, %for.body.lr.ph ], [ %i.inc, %for.inc ] + %within_limits = icmp ult i32 %i, 64 + %i.i64 = zext i32 %i to i64 + %arrayidx = getelementptr inbounds i32, i32* %base, i64 %i.i64 + %val = load i32, i32* %arrayidx, align 4 + br label %for.inc + +for.inc: + call void(i1, ...) @llvm.experimental.guard(i1 %within_limits) [ "deopt"() ] + %i.inc = add nsw nuw i32 %i, 1 + %cmp = icmp slt i32 %i.inc, %limit + br i1 %cmp, label %for.body, label %for.end + +for.end: + br label %exit + +exit: + ret void +} + +define void @test_guard_in_idom(i32* %base, i32 %limit, i32 %start) { +; CHECK-LABEL: @test_guard_in_idom( +; CHECK-NOT: trunc +; CHECK-NOT: icmp slt i32 + +for.body.lr.ph: + br label %for.body + +for.body: + %i = phi i32 [ %start, %for.body.lr.ph ], [ %i.inc, %for.inc ] + %within_limits = icmp ult i32 %i, 64 + call void(i1, ...) @llvm.experimental.guard(i1 %within_limits) [ "deopt"() ] + %i.i64 = zext i32 %i to i64 + %arrayidx = getelementptr inbounds i32, i32* %base, i64 %i.i64 + %val = load i32, i32* %arrayidx, align 4 + br label %for.inc + +for.inc: + %i.inc = add nsw nuw i32 %i, 1 + %cmp = icmp slt i32 %i.inc, %limit + br i1 %cmp, label %for.body, label %for.end + +for.end: + br label %exit + +exit: + ret void +} + +define void @test_guard_merge_ranges(i32* %base, i32 %limit, i32 %start) { +; CHECK-LABEL: @test_guard_merge_ranges( +; CHECK-NOT: trunc +; CHECK-NOT: icmp slt i32 + +for.body.lr.ph: + br label %for.body + +for.body: + %i = phi i32 [ %start, %for.body.lr.ph ], [ %i.inc, %for.body ] + %within_limits.1 = icmp ult i32 %i, 64 + call void(i1, ...) @llvm.experimental.guard(i1 %within_limits.1) [ "deopt"() ] + %within_limits.2 = icmp ult i32 %i, 2147483647 + call void(i1, ...) @llvm.experimental.guard(i1 %within_limits.2) [ "deopt"() ] + %i.i64 = zext i32 %i to i64 + %arrayidx = getelementptr inbounds i32, i32* %base, i64 %i.i64 + %val = load i32, i32* %arrayidx, align 4 + %i.inc = add nsw nuw i32 %i, 1 + %cmp = icmp slt i32 %i.inc, %limit + br i1 %cmp, label %for.body, label %for.end + +for.end: + br label %exit + +exit: + ret void +} |

