1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -simplifycfg < %s | FileCheck %s --check-prefix=ALL --check-prefix=EXPENSIVE
3 ; RUN: opt -S -simplifycfg -speculate-one-expensive-inst=false < %s | FileCheck %s --check-prefix=ALL --check-prefix=CHEAP
5 declare float @llvm.sqrt.f32(float) nounwind readonly
6 declare float @llvm.fma.f32(float, float, float) nounwind readonly
7 declare float @llvm.fmuladd.f32(float, float, float) nounwind readonly
8 declare float @llvm.fabs.f32(float) nounwind readonly
9 declare float @llvm.minnum.f32(float, float) nounwind readonly
10 declare float @llvm.maxnum.f32(float, float) nounwind readonly
11 declare float @llvm.minimum.f32(float, float) nounwind readonly
12 declare float @llvm.maximum.f32(float, float) nounwind readonly
14 define double @fdiv_test(double %a, double %b) {
15 ; ALL-LABEL: @fdiv_test(
17 ; ALL-NEXT: [[CMP:%.*]] = fcmp ogt double [[A:%.*]], 0.000000e+00
18 ; ALL-NEXT: [[DIV:%.*]] = fdiv double [[B:%.*]], [[A]]
19 ; ALL-NEXT: [[COND:%.*]] = select i1 [[CMP]], double [[DIV]], double 0.000000e+00
20 ; ALL-NEXT: ret double [[COND]]
23 %cmp = fcmp ogt double %a, 0.0
24 br i1 %cmp, label %cond.true, label %cond.end
27 %div = fdiv double %b, %a
31 %cond = phi double [ %div, %cond.true ], [ 0.0, %entry ]
35 define void @sqrt_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind {
36 ; ALL-LABEL: @sqrt_test(
38 ; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
39 ; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.sqrt.f32(float [[A]]) #2
40 ; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
41 ; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4
45 %cmp.i = fcmp olt float %a, 0.000000e+00
46 br i1 %cmp.i, label %test_sqrt.exit, label %cond.else.i
48 cond.else.i: ; preds = %entry
49 %0 = tail call float @llvm.sqrt.f32(float %a) nounwind readnone
50 br label %test_sqrt.exit
52 test_sqrt.exit: ; preds = %cond.else.i, %entry
53 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
54 store float %cond.i, float addrspace(1)* %out, align 4
58 define void @fabs_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind {
59 ; ALL-LABEL: @fabs_test(
61 ; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
62 ; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.fabs.f32(float [[A]]) #2
63 ; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
64 ; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4
68 %cmp.i = fcmp olt float %a, 0.000000e+00
69 br i1 %cmp.i, label %test_fabs.exit, label %cond.else.i
71 cond.else.i: ; preds = %entry
72 %0 = tail call float @llvm.fabs.f32(float %a) nounwind readnone
73 br label %test_fabs.exit
75 test_fabs.exit: ; preds = %cond.else.i, %entry
76 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
77 store float %cond.i, float addrspace(1)* %out, align 4
81 define void @fma_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
82 ; ALL-LABEL: @fma_test(
84 ; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
85 ; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.fma.f32(float [[A]], float [[B:%.*]], float [[C:%.*]]) #2
86 ; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
87 ; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4
91 %cmp.i = fcmp olt float %a, 0.000000e+00
92 br i1 %cmp.i, label %test_fma.exit, label %cond.else.i
94 cond.else.i: ; preds = %entry
95 %0 = tail call float @llvm.fma.f32(float %a, float %b, float %c) nounwind readnone
96 br label %test_fma.exit
98 test_fma.exit: ; preds = %cond.else.i, %entry
99 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
100 store float %cond.i, float addrspace(1)* %out, align 4
104 define void @fmuladd_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
105 ; ALL-LABEL: @fmuladd_test(
107 ; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
108 ; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.fmuladd.f32(float [[A]], float [[B:%.*]], float [[C:%.*]]) #2
109 ; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
110 ; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4
114 %cmp.i = fcmp olt float %a, 0.000000e+00
115 br i1 %cmp.i, label %test_fmuladd.exit, label %cond.else.i
117 cond.else.i: ; preds = %entry
118 %0 = tail call float @llvm.fmuladd.f32(float %a, float %b, float %c) nounwind readnone
119 br label %test_fmuladd.exit
121 test_fmuladd.exit: ; preds = %cond.else.i, %entry
122 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
123 store float %cond.i, float addrspace(1)* %out, align 4
127 define void @minnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
128 ; ALL-LABEL: @minnum_test(
130 ; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
131 ; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.minnum.f32(float [[A]], float [[B:%.*]]) #2
132 ; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
133 ; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4
137 %cmp.i = fcmp olt float %a, 0.000000e+00
138 br i1 %cmp.i, label %test_minnum.exit, label %cond.else.i
140 cond.else.i: ; preds = %entry
141 %0 = tail call float @llvm.minnum.f32(float %a, float %b) nounwind readnone
142 br label %test_minnum.exit
144 test_minnum.exit: ; preds = %cond.else.i, %entry
145 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
146 store float %cond.i, float addrspace(1)* %out, align 4
150 define void @maxnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
151 ; ALL-LABEL: @maxnum_test(
153 ; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
154 ; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.maxnum.f32(float [[A]], float [[B:%.*]]) #2
155 ; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
156 ; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4
160 %cmp.i = fcmp olt float %a, 0.000000e+00
161 br i1 %cmp.i, label %test_maxnum.exit, label %cond.else.i
163 cond.else.i: ; preds = %entry
164 %0 = tail call float @llvm.maxnum.f32(float %a, float %b) nounwind readnone
165 br label %test_maxnum.exit
167 test_maxnum.exit: ; preds = %cond.else.i, %entry
168 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
169 store float %cond.i, float addrspace(1)* %out, align 4
173 define void @minimum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
174 ; ALL-LABEL: @minimum_test(
176 ; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
177 ; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.minimum.f32(float [[A]], float [[B:%.*]]) #2
178 ; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
179 ; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4
183 %cmp.i = fcmp olt float %a, 0.000000e+00
184 br i1 %cmp.i, label %test_minimum.exit, label %cond.else.i
186 cond.else.i: ; preds = %entry
187 %0 = tail call float @llvm.minimum.f32(float %a, float %b) nounwind readnone
188 br label %test_minimum.exit
190 test_minimum.exit: ; preds = %cond.else.i, %entry
191 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
192 store float %cond.i, float addrspace(1)* %out, align 4
196 define void @maximum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
197 ; ALL-LABEL: @maximum_test(
199 ; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
200 ; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.maximum.f32(float [[A]], float [[B:%.*]]) #2
201 ; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
202 ; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4
206 %cmp.i = fcmp olt float %a, 0.000000e+00
207 br i1 %cmp.i, label %test_maximum.exit, label %cond.else.i
209 cond.else.i: ; preds = %entry
210 %0 = tail call float @llvm.maximum.f32(float %a, float %b) nounwind readnone
211 br label %test_maximum.exit
213 test_maximum.exit: ; preds = %cond.else.i, %entry
214 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
215 store float %cond.i, float addrspace(1)* %out, align 4