1 ; RUN: opt -S -simplifycfg < %s | FileCheck %s --check-prefix=EXPENSIVE --check-prefix=ALL
2 ; RUN: opt -S -simplifycfg -speculate-one-expensive-inst=false < %s | FileCheck %s --check-prefix=CHEAP --check-prefix=ALL
4 declare float @llvm.sqrt.f32(float) nounwind readonly
5 declare float @llvm.fma.f32(float, float, float) nounwind readonly
6 declare float @llvm.fmuladd.f32(float, float, float) nounwind readonly
7 declare float @llvm.fabs.f32(float) nounwind readonly
8 declare float @llvm.minnum.f32(float, float) nounwind readonly
9 declare float @llvm.maxnum.f32(float, float) nounwind readonly
10 declare float @llvm.minimum.f32(float, float) nounwind readonly
11 declare float @llvm.maximum.f32(float, float) nounwind readonly
13 ; ALL-LABEL: @fdiv_test(
14 ; EXPENSIVE: select i1 %cmp, double %div, double 0.0
17 define double @fdiv_test(double %a, double %b) {
19 %cmp = fcmp ogt double %a, 0.0
20 br i1 %cmp, label %cond.true, label %cond.end
23 %div = fdiv double %b, %a
27 %cond = phi double [ %div, %cond.true ], [ 0.0, %entry ]
31 ; ALL-LABEL: @sqrt_test(
33 define void @sqrt_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind {
35 %cmp.i = fcmp olt float %a, 0.000000e+00
36 br i1 %cmp.i, label %test_sqrt.exit, label %cond.else.i
38 cond.else.i: ; preds = %entry
39 %0 = tail call float @llvm.sqrt.f32(float %a) nounwind readnone
40 br label %test_sqrt.exit
42 test_sqrt.exit: ; preds = %cond.else.i, %entry
43 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
44 store float %cond.i, float addrspace(1)* %out, align 4
48 ; ALL-LABEL: @fabs_test(
50 define void @fabs_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind {
52 %cmp.i = fcmp olt float %a, 0.000000e+00
53 br i1 %cmp.i, label %test_fabs.exit, label %cond.else.i
55 cond.else.i: ; preds = %entry
56 %0 = tail call float @llvm.fabs.f32(float %a) nounwind readnone
57 br label %test_fabs.exit
59 test_fabs.exit: ; preds = %cond.else.i, %entry
60 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
61 store float %cond.i, float addrspace(1)* %out, align 4
65 ; ALL-LABEL: @fma_test(
67 define void @fma_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
69 %cmp.i = fcmp olt float %a, 0.000000e+00
70 br i1 %cmp.i, label %test_fma.exit, label %cond.else.i
72 cond.else.i: ; preds = %entry
73 %0 = tail call float @llvm.fma.f32(float %a, float %b, float %c) nounwind readnone
74 br label %test_fma.exit
76 test_fma.exit: ; preds = %cond.else.i, %entry
77 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
78 store float %cond.i, float addrspace(1)* %out, align 4
82 ; ALL-LABEL: @fmuladd_test(
84 define void @fmuladd_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
86 %cmp.i = fcmp olt float %a, 0.000000e+00
87 br i1 %cmp.i, label %test_fmuladd.exit, label %cond.else.i
89 cond.else.i: ; preds = %entry
90 %0 = tail call float @llvm.fmuladd.f32(float %a, float %b, float %c) nounwind readnone
91 br label %test_fmuladd.exit
93 test_fmuladd.exit: ; preds = %cond.else.i, %entry
94 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
95 store float %cond.i, float addrspace(1)* %out, align 4
99 ; ALL-LABEL: @minnum_test(
101 define void @minnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
103 %cmp.i = fcmp olt float %a, 0.000000e+00
104 br i1 %cmp.i, label %test_minnum.exit, label %cond.else.i
106 cond.else.i: ; preds = %entry
107 %0 = tail call float @llvm.minnum.f32(float %a, float %b) nounwind readnone
108 br label %test_minnum.exit
110 test_minnum.exit: ; preds = %cond.else.i, %entry
111 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
112 store float %cond.i, float addrspace(1)* %out, align 4
116 ; ALL-LABEL: @maxnum_test(
118 define void @maxnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
120 %cmp.i = fcmp olt float %a, 0.000000e+00
121 br i1 %cmp.i, label %test_maxnum.exit, label %cond.else.i
123 cond.else.i: ; preds = %entry
124 %0 = tail call float @llvm.maxnum.f32(float %a, float %b) nounwind readnone
125 br label %test_maxnum.exit
127 test_maxnum.exit: ; preds = %cond.else.i, %entry
128 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
129 store float %cond.i, float addrspace(1)* %out, align 4
133 ; ALL-LABEL: @minimum_test(
135 define void @minimum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
137 %cmp.i = fcmp olt float %a, 0.000000e+00
138 br i1 %cmp.i, label %test_minimum.exit, label %cond.else.i
140 cond.else.i: ; preds = %entry
141 %0 = tail call float @llvm.minimum.f32(float %a, float %b) nounwind readnone
142 br label %test_minimum.exit
144 test_minimum.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 ; ALL-LABEL: @maximum_test(
152 define void @maximum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
154 %cmp.i = fcmp olt float %a, 0.000000e+00
155 br i1 %cmp.i, label %test_maximum.exit, label %cond.else.i
157 cond.else.i: ; preds = %entry
158 %0 = tail call float @llvm.maximum.f32(float %a, float %b) nounwind readnone
159 br label %test_maximum.exit
161 test_maximum.exit: ; preds = %cond.else.i, %entry
162 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
163 store float %cond.i, float addrspace(1)* %out, align 4