summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/SimplifyCFG/switch_thread.ll
diff options
context:
space:
mode:
authorShawn Landden <shawn@git.icu>2019-06-13 04:51:35 +0000
committerShawn Landden <shawn@git.icu>2019-06-13 04:51:35 +0000
commitc54b2011bd0791260e049b0acabd63cf1438aa95 (patch)
tree76b8430512ce77e34650419ed1271d54fc822dad /llvm/test/Transforms/SimplifyCFG/switch_thread.ll
parentc2e2df7f7af139ff2edb0563bfe48896d841c5e2 (diff)
downloadbcm5719-llvm-c54b2011bd0791260e049b0acabd63cf1438aa95.tar.gz
bcm5719-llvm-c54b2011bd0791260e049b0acabd63cf1438aa95.zip
[SimplifyCFG] NFC, update Switch tests to better examine successive patches
Also add baseline tests to show effect of later patches. There were a couple of regressions here that were never caught, but my patch set that this is a preparation to will fix them. Differential Revision: https://reviews.llvm.org/D61150 llvm-svn: 363226
Diffstat (limited to 'llvm/test/Transforms/SimplifyCFG/switch_thread.ll')
-rw-r--r--llvm/test/Transforms/SimplifyCFG/switch_thread.ll153
1 files changed, 78 insertions, 75 deletions
diff --git a/llvm/test/Transforms/SimplifyCFG/switch_thread.ll b/llvm/test/Transforms/SimplifyCFG/switch_thread.ll
index 32e0325df7f..e38865699d2 100644
--- a/llvm/test/Transforms/SimplifyCFG/switch_thread.ll
+++ b/llvm/test/Transforms/SimplifyCFG/switch_thread.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -simplifycfg -S | FileCheck %s
; Test that we can thread a simple known condition through switch statements.
@@ -9,97 +10,70 @@ declare void @foo2()
declare void @DEAD()
define void @test1(i32 %V) {
- switch i32 %V, label %A [
- i32 4, label %T
- i32 17, label %Done
- i32 1234, label %A
- ]
-;; V == 4 if we get here.
-T: ; preds = %0
- call void @foo1( )
- ;; This switch is always statically determined.
- switch i32 %V, label %A2 [
- i32 4, label %B
- i32 17, label %C
- i32 42, label %C
- ]
-A2: ; preds = %T
- call void @DEAD( )
- call void @DEAD( )
- ;; always true
- %cond2 = icmp eq i32 %V, 4 ; <i1> [#uses=1]
- br i1 %cond2, label %Done, label %C
-A: ; preds = %0, %0
- call void @foo1( )
- ;; always true
- %cond = icmp ne i32 %V, 4 ; <i1> [#uses=1]
- br i1 %cond, label %Done, label %C
-Done: ; preds = %B, %A, %A2, %0
- ret void
-B: ; preds = %T
- call void @foo2( )
- ;; always true
- %cond3 = icmp eq i32 %V, 4 ; <i1> [#uses=1]
- br i1 %cond3, label %Done, label %C
-C: ; preds = %B, %A, %A2, %T, %T
- call void @DEAD( )
- ret void
-
; CHECK-LABEL: @test1(
-; CHECK-NEXT: switch i32 %V, label %A [
-; CHECK-NEXT: i32 4, label %T
-; CHECK-NEXT: i32 17, label %Done
+; CHECK-NEXT: switch i32 [[V:%.*]], label [[A:%.*]] [
+; CHECK-NEXT: i32 4, label [[T:%.*]]
+; CHECK-NEXT: i32 17, label [[DONE:%.*]]
; CHECK-NEXT: ]
; CHECK: T:
; CHECK-NEXT: call void @foo1()
; CHECK-NEXT: call void @foo2()
-; CHECK-NEXT: br label %Done
+; CHECK-NEXT: br label [[DONE]]
; CHECK: A:
; CHECK-NEXT: call void @foo1()
-; CHECK-NEXT: br label %Done
+; CHECK-NEXT: br label [[DONE]]
; CHECK: Done:
; CHECK-NEXT: ret void
+;
+ switch i32 %V, label %A [
+ i32 4, label %T
+ i32 17, label %Done
+ i32 1234, label %A
+ ]
+;; V == 4 if we get here.
+T: ; preds = %0
+ call void @foo1( )
+ ;; This switch is always statically determined.
+ switch i32 %V, label %A2 [
+ i32 4, label %B
+ i32 17, label %C
+ i32 42, label %C
+ ]
+A2: ; preds = %T
+ call void @DEAD( )
+ call void @DEAD( )
+ ;; always true
+ %cond2 = icmp eq i32 %V, 4 ; <i1> [#uses=1]
+ br i1 %cond2, label %Done, label %C
+A: ; preds = %0, %0
+ call void @foo1( )
+ ;; always true
+ %cond = icmp ne i32 %V, 4 ; <i1> [#uses=1]
+ br i1 %cond, label %Done, label %C
+Done: ; preds = %B, %A, %A2, %0
+ ret void
+B: ; preds = %T
+ call void @foo2( )
+ ;; always true
+ %cond3 = icmp eq i32 %V, 4 ; <i1> [#uses=1]
+ br i1 %cond3, label %Done, label %C
+C: ; preds = %B, %A, %A2, %T, %T
+ call void @DEAD( )
+ ret void
+
}
define void @test2(i32 %V) {
- switch i32 %V, label %A [
- i32 4, label %T
- i32 17, label %D
- i32 1234, label %E
- ]
-;; V != 4, 17, 1234 here.
-A: ; preds = %0
- call void @foo1( )
- ;; This switch is always statically determined.
- switch i32 %V, label %E [
- i32 4, label %C
- i32 17, label %C
- i32 42, label %D
- ]
-;; unreacahble.
-C: ; preds = %A, %A
- call void @DEAD( )
- ret void
-T: ; preds = %0
- call void @foo1( )
- call void @foo1( )
- ret void
-D: ; preds = %A, %0
- call void @foo1( )
- ret void
-E: ; preds = %A, %0
- ret void
-
; CHECK-LABEL: @test2(
-; CHECK-NEXT: switch i32 %V, label %A [
-; CHECK-NEXT: i32 4, label %T
-; CHECK-NEXT: i32 17, label %D
-; CHECK-NEXT: i32 1234, label %E
+; CHECK-NEXT: switch i32 [[V:%.*]], label [[A:%.*]] [
+; CHECK-NEXT: i32 4, label [[T:%.*]]
+; CHECK-NEXT: i32 17, label [[D:%.*]]
+; CHECK-NEXT: i32 1234, label [[E:%.*]]
; CHECK-NEXT: ]
; CHECK: A:
; CHECK-NEXT: call void @foo1()
-; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 %V, 42
-; CHECK-NEXT: br i1 [[COND]], label %D, label %E
+; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[V]], 42
+; CHECK-NEXT: br i1 [[COND]], label [[D]], label [[E]]
; CHECK: T:
; CHECK-NEXT: call void @foo1()
; CHECK-NEXT: call void @foo1()
@@ -109,5 +83,34 @@ E: ; preds = %A, %0
; CHECK-NEXT: ret void
; CHECK: E:
; CHECK-NEXT: ret void
+;
+ switch i32 %V, label %A [
+ i32 4, label %T
+ i32 17, label %D
+ i32 1234, label %E
+ ]
+;; V != 4, 17, 1234 here.
+A: ; preds = %0
+ call void @foo1( )
+ ;; This switch is always statically determined.
+ switch i32 %V, label %E [
+ i32 4, label %C
+ i32 17, label %C
+ i32 42, label %D
+ ]
+;; unreacahble.
+C: ; preds = %A, %A
+ call void @DEAD( )
+ ret void
+T: ; preds = %0
+ call void @foo1( )
+ call void @foo1( )
+ ret void
+D: ; preds = %A, %0
+ call void @foo1( )
+ ret void
+E: ; preds = %A, %0
+ ret void
+
}
OpenPOWER on IntegriCloud