1 ; RUN: opt < %s -passes=correlated-propagation -S | FileCheck %s
3 ; Removed several cases from switch.
4 define i32 @switch1(i32 %s) {
5 ; CHECK-LABEL: @switch1(
7 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[S:%.*]], 0
8 ; CHECK-NEXT: br i1 [[CMP]], label [[NEGATIVE:%.*]], label [[OUT:%.*]]
11 %cmp = icmp slt i32 %s, 0
12 br i1 %cmp, label %negative, label %out
16 ; CHECK-NEXT: switch i32 [[S]], label [[OUT]] [
17 ; CHECK-NEXT: i32 -2, label [[NEXT:%.*]]
18 ; CHECK-NEXT: i32 -1, label [[NEXT]]
19 switch i32 %s, label %out [
26 ; CHECK-NEXT: !prof ![[MD0:[0-9]+]]
27 ], !prof !{!"branch_weights", i32 99, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6}
30 %p = phi i32 [ 1, %entry ], [ -1, %negative ], [ -1, %negative ], [ -1, %negative ], [ -1, %negative ], [ -1, %negative ]
34 %q = phi i32 [ 0, %negative ], [ 0, %negative ]
38 ; Removed all cases from switch.
39 define i32 @switch2(i32 %s) {
40 ; CHECK-LABEL: @switch2(
42 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[S:%.*]], 0
43 ; CHECK-NEXT: br i1 [[CMP]], label [[POSITIVE:%.*]], label [[OUT:%.*]]
46 %cmp = icmp sgt i32 %s, 0
47 br i1 %cmp, label %positive, label %out
50 switch i32 %s, label %out [
54 ], !prof !{!"branch_weights", i32 99, i32 1, i32 2, i32 3}
57 %p = phi i32 [ -1, %entry ], [ 1, %positive ], [ 1, %positive ]
61 %q = phi i32 [ 0, %positive ], [ 0, %positive ]
65 ; Change switch into conditional branch.
66 define i32 @switch3(i32 %s) {
67 ; CHECK-LABEL: @switch3(
70 %cmp = icmp sgt i32 %s, 0
71 br i1 %cmp, label %positive, label %out
75 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 %s, 1
76 ; CHECK-NEXT: br i1 [[CMP]], label [[NEXT:%.*]], label [[OUT:%.*]], !prof ![[MD1:[0-9]+]]
77 switch i32 %s, label %out [
81 ], !prof !{!"branch_weights", i32 99, i32 1, i32 2, i32 3}
84 %p = phi i32 [ -1, %entry ], [ 1, %positive ]
88 %q = phi i32 [ 0, %positive ], [ 0, %positive ], [ 0, %positive ]
92 ; Removed all cases from switch.
93 define i32 @switch4(i32 %s) {
94 ; CHECK-LABEL: @switch4(
96 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[S:%.*]], 0
97 ; CHECK-NEXT: br i1 [[CMP]], label [[NEGATIVE:%.*]], label [[OUT:%.*]]
100 %cmp = icmp slt i32 %s, 0
101 br i1 %cmp, label %negative, label %out
105 ; CHECK-NEXT: br label %out
106 switch i32 %s, label %out [
111 ], !prof !{!"branch_weights", i32 99, i32 1, i32 2, i32 3, i32 4}
114 %p = phi i32 [ 1, %entry ], [ -1, %negative ], [ -1, %negative ], [ -1, %negative ], [ -1, %negative ], [ -1, %negative ]
118 ; CHECK: ![[MD0]] = !{!"branch_weights", i32 99, i32 4, i32 3}
119 ; CHECK: ![[MD1]] = !{!"branch_weights", i32 1, i32 99}