diff options
| author | Craig Topper <craig.topper@gmail.com> | 2017-06-27 15:26:47 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@gmail.com> | 2017-06-27 15:26:47 +0000 |
| commit | 0a60d8581116193d254cc7ce64e29d0294f1c53f (patch) | |
| tree | 5cea4adafeee4cacf72eaedc2d61674a66f88674 /llvm/test/Transforms/JumpThreading | |
| parent | 80296ee7f376366c410b2140bce459eb9d5169d7 (diff) | |
| download | bcm5719-llvm-0a60d8581116193d254cc7ce64e29d0294f1c53f.tar.gz bcm5719-llvm-0a60d8581116193d254cc7ce64e29d0294f1c53f.zip | |
[JumpThreading] Add test case that was supposed to go with r306085.
Looks like I forgot to 'git add' when I submitted the commit. Thanks to Chandler for noticing.
llvm-svn: 306416
Diffstat (limited to 'llvm/test/Transforms/JumpThreading')
| -rw-r--r-- | llvm/test/Transforms/JumpThreading/range-compare.ll | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/llvm/test/Transforms/JumpThreading/range-compare.ll b/llvm/test/Transforms/JumpThreading/range-compare.ll new file mode 100644 index 00000000000..54e94d06649 --- /dev/null +++ b/llvm/test/Transforms/JumpThreading/range-compare.ll @@ -0,0 +1,125 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +;RUN: opt < %s -jump-threading -S | FileCheck %s + + +declare void @bar(...) +declare void @baz(...) + +; Make sure we thread the end of the bar block to the end of the function. +define void @test1(i32 %x) { +; CHECK-LABEL: @test1( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 9 +; CHECK-NEXT: br i1 [[CMP]], label [[IF_END_THREAD:%.*]], label [[IF_END:%.*]] +; CHECK: if.end.thread: +; CHECK-NEXT: call void (...) @bar() +; CHECK-NEXT: br label [[IF_END4:%.*]] +; CHECK: if.end: +; CHECK-NEXT: [[X_OFF:%.*]] = add i32 [[X]], -3 +; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i32 [[X_OFF]], 5 +; CHECK-NEXT: br i1 [[TMP0]], label [[IF_THEN3:%.*]], label [[IF_END4]] +; CHECK: if.then3: +; CHECK-NEXT: call void (...) @baz() +; CHECK-NEXT: br label [[IF_END4]] +; CHECK: if.end4: +; CHECK-NEXT: ret void +; +entry: + %cmp = icmp sgt i32 %x, 9 + br i1 %cmp, label %if.then, label %if.end + +if.then: ; preds = %entry + call void (...) @bar() + br label %if.end + +if.end: ; preds = %if.then, %entry + %x.off = add i32 %x, -3 + %0 = icmp ult i32 %x.off, 5 + br i1 %0, label %if.then3, label %if.end4 + +if.then3: ; preds = %if.end + call void (...) @baz() + br label %if.end4 + +if.end4: ; preds = %if.then3, %if.end + ret void +} + +; Make sure we thread the false side of the first if to the end of the function. +define void @test2(i32 %x) { +; CHECK-LABEL: @test2( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 9 +; CHECK-NEXT: br i1 [[CMP]], label [[IF_END:%.*]], label [[IF_END4:%.*]] +; CHECK: if.end: +; CHECK-NEXT: call void (...) @bar() +; CHECK-NEXT: [[X_OFF:%.*]] = add i32 [[X]], -3 +; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i32 [[X_OFF]], 5 +; CHECK-NEXT: br i1 [[TMP0]], label [[IF_THEN3:%.*]], label [[IF_END4]] +; CHECK: if.then3: +; CHECK-NEXT: call void (...) @baz() +; CHECK-NEXT: br label [[IF_END4]] +; CHECK: if.end4: +; CHECK-NEXT: ret void +; +entry: + %cmp = icmp slt i32 %x, 9 + br i1 %cmp, label %if.then, label %if.end + +if.then: ; preds = %entry + call void (...) @bar() + br label %if.end + +if.end: ; preds = %if.then, %entry + %x.off = add i32 %x, -3 + %0 = icmp ult i32 %x.off, 5 + br i1 %0, label %if.then3, label %if.end4 + +if.then3: ; preds = %if.end + call void (...) @baz() + br label %if.end4 + +if.end4: ; preds = %if.then3, %if.end + ret void +} + +; Negative test to make sure we don't thread when the ranges overlap. +define void @test3(i32 %x) { +; CHECK-LABEL: @test3( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 6 +; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] +; CHECK: if.then: +; CHECK-NEXT: call void (...) @bar() +; CHECK-NEXT: br label [[IF_END]] +; CHECK: if.end: +; CHECK-NEXT: [[X_OFF:%.*]] = add i32 [[X]], -3 +; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i32 [[X_OFF]], 5 +; CHECK-NEXT: br i1 [[TMP0]], label [[IF_THEN3:%.*]], label [[IF_END4:%.*]] +; CHECK: if.then3: +; CHECK-NEXT: call void (...) @baz() +; CHECK-NEXT: br label [[IF_END4]] +; CHECK: if.end4: +; CHECK-NEXT: ret void +; +entry: + %cmp = icmp sgt i32 %x, 6 + br i1 %cmp, label %if.then, label %if.end + +if.then: ; preds = %entry + call void (...) @bar() + br label %if.end + +if.end: ; preds = %if.then, %entry + %x.off = add i32 %x, -3 + %0 = icmp ult i32 %x.off, 5 + br i1 %0, label %if.then3, label %if.end4 + +if.then3: ; preds = %if.end + call void (...) @baz() + br label %if.end4 + +if.end4: ; preds = %if.then3, %if.end + ret void +} + |

