1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=newgvn -S | FileCheck %s
5 ;; Block 6 is reachable, but edge 6->4 is not
6 ;; This means the phi value is undef, not 0
7 ; Function Attrs: ssp uwtable
11 ; CHECK-NEXT: switch i8 undef, label [[BB7:%.*]] [
12 ; CHECK-NEXT: i8 0, label [[BB1:%.*]]
13 ; CHECK-NEXT: i8 12, label [[BB2:%.*]]
16 ; CHECK-NEXT: br label [[BB6:%.*]]
18 ; CHECK-NEXT: br label [[BB4:%.*]]
20 ; CHECK-NEXT: unreachable
22 ; CHECK-NEXT: ret i16 undef
24 ; CHECK-NEXT: br i1 true, label [[BB3:%.*]], label [[BB4]]
26 ; CHECK-NEXT: unreachable
29 switch i8 undef, label %bb7 [
43 bb4: ; preds = %bb6, %bb2
44 %tmp = phi i16 [ 0, %bb6 ], [ undef, %bb2 ]
48 br i1 true, label %bb3, label %bb4
54 define i8 @only_undef(i1 %cond) {
55 ; CHECK-LABEL: @only_undef(
56 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[A:%.*]], label [[B:%.*]]
58 ; CHECK-NEXT: br label [[EXIT:%.*]]
60 ; CHECK-NEXT: br label [[EXIT]]
62 ; CHECK-NEXT: ret i8 undef
64 br i1 %cond, label %A, label %B
70 %r = phi i8 [undef, %A], [undef, %B]
74 define i8 @only_poison(i1 %cond) {
75 ; CHECK-LABEL: @only_poison(
76 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[A:%.*]], label [[B:%.*]]
78 ; CHECK-NEXT: br label [[EXIT:%.*]]
80 ; CHECK-NEXT: br label [[EXIT]]
82 ; CHECK-NEXT: ret i8 poison
84 br i1 %cond, label %A, label %B
90 %r = phi i8 [poison, %A], [poison, %B]
94 define i8 @undef_poison(i1 %cond) {
95 ; CHECK-LABEL: @undef_poison(
96 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[A:%.*]], label [[B:%.*]]
98 ; CHECK-NEXT: br label [[EXIT:%.*]]
100 ; CHECK-NEXT: br label [[EXIT]]
102 ; CHECK-NEXT: ret i8 undef
104 br i1 %cond, label %A, label %B
110 %r = phi i8 [undef, %A], [poison, %B]
114 define i8 @value_undef(i1 %cond, i8 %v) {
115 ; CHECK-LABEL: @value_undef(
116 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[A:%.*]], label [[B:%.*]]
118 ; CHECK-NEXT: br label [[EXIT:%.*]]
120 ; CHECK-NEXT: br label [[EXIT]]
122 ; CHECK-NEXT: [[R:%.*]] = phi i8 [ undef, [[A]] ], [ [[V:%.*]], [[B]] ]
123 ; CHECK-NEXT: ret i8 [[R]]
125 br i1 %cond, label %A, label %B
131 %r = phi i8 [undef, %A], [%v, %B]
135 define i8 @value_undef_noundef(i1 %cond, i8 noundef %v) {
136 ; CHECK-LABEL: @value_undef_noundef(
137 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[A:%.*]], label [[B:%.*]]
139 ; CHECK-NEXT: br label [[EXIT:%.*]]
141 ; CHECK-NEXT: br label [[EXIT]]
143 ; CHECK-NEXT: ret i8 [[V:%.*]]
145 br i1 %cond, label %A, label %B
151 %r = phi i8 [undef, %A], [%v, %B]
155 define i8 @value_poison(i1 %cond, i8 %v) {
156 ; CHECK-LABEL: @value_poison(
157 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[A:%.*]], label [[B:%.*]]
159 ; CHECK-NEXT: br label [[EXIT:%.*]]
161 ; CHECK-NEXT: br label [[EXIT]]
163 ; CHECK-NEXT: ret i8 [[V:%.*]]
165 br i1 %cond, label %A, label %B
171 %r = phi i8 [poison, %A], [%v, %B]