1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -print-predicateinfo -analyze < %s 2>&1 | FileCheck %s
4 define i32 @f1(i32 %x) {
7 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X:%.*]], 0
8 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
9 ; CHECK-NEXT: br i1 [[CMP]], label [[BB2:%.*]], label [[BB1:%.*]]
11 ; CHECK-NEXT: br label [[BB2]]
13 ; CHECK-NEXT: [[COND:%.*]] = phi i32 [ [[X_0]], [[BB0:%.*]] ], [ 0, [[BB1]] ]
14 ; CHECK-NEXT: [[FOO:%.*]] = add i32 [[COND]], [[X]]
15 ; CHECK-NEXT: ret i32 [[FOO]]
18 %cmp = icmp eq i32 %x, 0
19 br i1 %cmp, label %bb2, label %bb1
23 %cond = phi i32 [ %x, %bb0 ], [ 0, %bb1 ]
24 %foo = add i32 %cond, %x
28 define i32 @f2(i32 %x) {
31 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[X:%.*]], 0
32 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
33 ; CHECK-NEXT: br i1 [[CMP]], label [[BB1:%.*]], label [[BB2:%.*]]
35 ; CHECK-NEXT: br label [[BB2]]
37 ; CHECK-NEXT: [[COND:%.*]] = phi i32 [ [[X_0]], [[BB0:%.*]] ], [ 0, [[BB1]] ]
38 ; CHECK-NEXT: [[FOO:%.*]] = add i32 [[COND]], [[X]]
39 ; CHECK-NEXT: ret i32 [[FOO]]
42 %cmp = icmp ne i32 %x, 0
43 br i1 %cmp, label %bb1, label %bb2
47 %cond = phi i32 [ %x, %bb0 ], [ 0, %bb1 ]
48 %foo = add i32 %cond, %x
52 define i32 @f3(i32 %x) {
55 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X:%.*]])
56 ; CHECK-NEXT: switch i32 [[X]], label [[BB1:%.*]] [
57 ; CHECK-NEXT: i32 0, label [[BB2:%.*]]
60 ; CHECK-NEXT: br label [[BB2]]
62 ; CHECK-NEXT: [[COND:%.*]] = phi i32 [ [[X_0]], [[BB0:%.*]] ], [ 0, [[BB1]] ]
63 ; CHECK-NEXT: [[FOO:%.*]] = add i32 [[COND]], [[X]]
64 ; CHECK-NEXT: ret i32 [[FOO]]
67 switch i32 %x, label %bb1 [ i32 0, label %bb2]
71 %cond = phi i32 [ %x, %bb0 ], [ 0, %bb1 ]
72 %foo = add i32 %cond, %x
77 define double @fcmp_oeq_not_zero(double %x, double %y) {
78 ; CHECK-LABEL: @fcmp_oeq_not_zero(
80 ; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq double [[Y:%.*]], 2.000000e+00
81 ; CHECK: [[Y_0:%.*]] = call double @llvm.ssa.copy.{{.+}}(double [[Y]])
82 ; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[RETURN:%.*]]
84 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[X:%.*]], [[Y_0]]
85 ; CHECK-NEXT: br label [[RETURN]]
87 ; CHECK-NEXT: [[RETVAL:%.*]] = phi double [ [[DIV]], [[IF]] ], [ [[X]], [[ENTRY:%.*]] ]
88 ; CHECK-NEXT: ret double [[RETVAL]]
91 %cmp = fcmp oeq double %y, 2.0
92 br i1 %cmp, label %if, label %return
95 %div = fdiv double %x, %y
99 %retval = phi double [ %div, %if ], [ %x, %entry ]
104 define double @fcmp_une_not_zero(double %x, double %y) {
105 ; CHECK-LABEL: @fcmp_une_not_zero(
107 ; CHECK-NEXT: [[CMP:%.*]] = fcmp une double [[Y:%.*]], 2.000000e+00
108 ; CHECK: [[Y_0:%.*]] = call double @llvm.ssa.copy.{{.+}}(double [[Y]])
109 ; CHECK-NEXT: br i1 [[CMP]], label [[RETURN:%.*]], label [[ELSE:%.*]]
111 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[X:%.*]], [[Y_0]]
112 ; CHECK-NEXT: br label [[RETURN]]
114 ; CHECK-NEXT: [[RETVAL:%.*]] = phi double [ [[DIV]], [[ELSE]] ], [ [[X]], [[ENTRY:%.*]] ]
115 ; CHECK-NEXT: ret double [[RETVAL]]
118 %cmp = fcmp une double %y, 2.0
119 br i1 %cmp, label %return, label %else
122 %div = fdiv double %x, %y
126 %retval = phi double [ %div, %else ], [ %x, %entry ]
131 define double @fcmp_oeq_zero(double %x, double %y) {
132 ; CHECK-LABEL: @fcmp_oeq_zero(
134 ; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq double [[Y:%.*]], 0.000000e+00
135 ; CHECK: [[Y_0:%.*]] = call double @llvm.ssa.copy.{{.+}}(double [[Y]])
136 ; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[RETURN:%.*]]
138 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[X:%.*]], [[Y_0]]
139 ; CHECK-NEXT: br label [[RETURN]]
141 ; CHECK-NEXT: [[RETVAL:%.*]] = phi double [ [[DIV]], [[IF]] ], [ [[X]], [[ENTRY:%.*]] ]
142 ; CHECK-NEXT: ret double [[RETVAL]]
145 %cmp = fcmp oeq double %y, 0.0
146 br i1 %cmp, label %if, label %return
149 %div = fdiv double %x, %y
153 %retval = phi double [ %div, %if ], [ %x, %entry ]
158 define double @fcmp_une_zero(double %x, double %y) {
159 ; CHECK-LABEL: @fcmp_une_zero(
161 ; CHECK-NEXT: [[CMP:%.*]] = fcmp une double [[Y:%.*]], -0.000000e+00
162 ; CHECK: [[Y_0:%.*]] = call double @llvm.ssa.copy.{{.+}}(double [[Y]])
163 ; CHECK-NEXT: br i1 [[CMP]], label [[RETURN:%.*]], label [[ELSE:%.*]]
165 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[X:%.*]], [[Y_0]]
166 ; CHECK-NEXT: br label [[RETURN]]
168 ; CHECK-NEXT: [[RETVAL:%.*]] = phi double [ [[DIV]], [[ELSE]] ], [ [[X]], [[ENTRY:%.*]] ]
169 ; CHECK-NEXT: ret double [[RETVAL]]
172 %cmp = fcmp une double %y, -0.0
173 br i1 %cmp, label %return, label %else
176 %div = fdiv double %x, %y
180 %retval = phi double [ %div, %else ], [ %x, %entry ]
186 define double @fcmp_oeq_maybe_zero(double %x, double %y, double %z1, double %z2) {
187 ; CHECK-LABEL: @fcmp_oeq_maybe_zero(
189 ; CHECK-NEXT: [[Z:%.*]] = fadd double [[Z1:%.*]], [[Z2:%.*]]
190 ; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq double [[Y:%.*]], [[Z]]
191 ; CHECK: [[Z_0:%.*]] = call double @llvm.ssa.copy.{{.+}}(double [[Z]])
192 ; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[RETURN:%.*]]
194 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[X:%.*]], [[Z_0]]
195 ; CHECK-NEXT: br label [[RETURN]]
197 ; CHECK-NEXT: [[RETVAL:%.*]] = phi double [ [[DIV]], [[IF]] ], [ [[X]], [[ENTRY:%.*]] ]
198 ; CHECK-NEXT: ret double [[RETVAL]]
201 %z = fadd double %z1, %z2
202 %cmp = fcmp oeq double %y, %z
203 br i1 %cmp, label %if, label %return
206 %div = fdiv double %x, %z
210 %retval = phi double [ %div, %if ], [ %x, %entry ]
215 define double @fcmp_une_maybe_zero(double %x, double %y, double %z1, double %z2) {
216 ; CHECK-LABEL: @fcmp_une_maybe_zero(
218 ; CHECK-NEXT: [[Z:%.*]] = fadd double [[Z1:%.*]], [[Z2:%.*]]
219 ; CHECK-NEXT: [[CMP:%.*]] = fcmp une double [[Y:%.*]], [[Z]]
220 ; CHECK: [[Z_0:%.*]] = call double @llvm.ssa.copy.{{.+}}(double [[Z]])
221 ; CHECK-NEXT: br i1 [[CMP]], label [[RETURN:%.*]], label [[ELSE:%.*]]
223 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[X:%.*]], [[Z_0]]
224 ; CHECK-NEXT: br label [[RETURN]]
226 ; CHECK-NEXT: [[RETVAL:%.*]] = phi double [ [[DIV]], [[ELSE]] ], [ [[X]], [[ENTRY:%.*]] ]
227 ; CHECK-NEXT: ret double [[RETVAL]]
230 %z = fadd double %z1, %z2
231 %cmp = fcmp une double %y, %z
232 br i1 %cmp, label %return, label %else
235 %div = fdiv double %x, %z
239 %retval = phi double [ %div, %else ], [ %x, %entry ]