blob: 87e01663edf42a4b5c84091b3ad3b63539c9c0f9 [file] [log] [blame]
Eric Christophercee313d2019-04-17 04:52:47 +00001; 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
3
4declare float @llvm.sqrt.f32(float) nounwind readonly
5declare float @llvm.fma.f32(float, float, float) nounwind readonly
6declare float @llvm.fmuladd.f32(float, float, float) nounwind readonly
7declare float @llvm.fabs.f32(float) nounwind readonly
8declare float @llvm.minnum.f32(float, float) nounwind readonly
9declare float @llvm.maxnum.f32(float, float) nounwind readonly
10declare float @llvm.minimum.f32(float, float) nounwind readonly
11declare float @llvm.maximum.f32(float, float) nounwind readonly
12
13; ALL-LABEL: @fdiv_test(
14; EXPENSIVE: select i1 %cmp, double %div, double 0.0
15; CHEAP-NOT: select
16
17define double @fdiv_test(double %a, double %b) {
18entry:
19 %cmp = fcmp ogt double %a, 0.0
20 br i1 %cmp, label %cond.true, label %cond.end
21
22cond.true:
23 %div = fdiv double %b, %a
24 br label %cond.end
25
26cond.end:
27 %cond = phi double [ %div, %cond.true ], [ 0.0, %entry ]
28 ret double %cond
29}
30
31; ALL-LABEL: @sqrt_test(
32; ALL: select
33define void @sqrt_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind {
34entry:
35 %cmp.i = fcmp olt float %a, 0.000000e+00
36 br i1 %cmp.i, label %test_sqrt.exit, label %cond.else.i
37
38cond.else.i: ; preds = %entry
39 %0 = tail call float @llvm.sqrt.f32(float %a) nounwind readnone
40 br label %test_sqrt.exit
41
42test_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
45 ret void
46}
47
48; ALL-LABEL: @fabs_test(
49; ALL: select
50define void @fabs_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind {
51entry:
52 %cmp.i = fcmp olt float %a, 0.000000e+00
53 br i1 %cmp.i, label %test_fabs.exit, label %cond.else.i
54
55cond.else.i: ; preds = %entry
56 %0 = tail call float @llvm.fabs.f32(float %a) nounwind readnone
57 br label %test_fabs.exit
58
59test_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
62 ret void
63}
64
65; ALL-LABEL: @fma_test(
66; ALL: select
67define void @fma_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
68entry:
69 %cmp.i = fcmp olt float %a, 0.000000e+00
70 br i1 %cmp.i, label %test_fma.exit, label %cond.else.i
71
72cond.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
75
76test_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
79 ret void
80}
81
82; ALL-LABEL: @fmuladd_test(
83; ALL: select
84define void @fmuladd_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
85entry:
86 %cmp.i = fcmp olt float %a, 0.000000e+00
87 br i1 %cmp.i, label %test_fmuladd.exit, label %cond.else.i
88
89cond.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
92
93test_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
96 ret void
97}
98
99; ALL-LABEL: @minnum_test(
100; ALL: select
101define void @minnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
102entry:
103 %cmp.i = fcmp olt float %a, 0.000000e+00
104 br i1 %cmp.i, label %test_minnum.exit, label %cond.else.i
105
106cond.else.i: ; preds = %entry
107 %0 = tail call float @llvm.minnum.f32(float %a, float %b) nounwind readnone
108 br label %test_minnum.exit
109
110test_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
113 ret void
114}
115
116; ALL-LABEL: @maxnum_test(
117; ALL: select
118define void @maxnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
119entry:
120 %cmp.i = fcmp olt float %a, 0.000000e+00
121 br i1 %cmp.i, label %test_maxnum.exit, label %cond.else.i
122
123cond.else.i: ; preds = %entry
124 %0 = tail call float @llvm.maxnum.f32(float %a, float %b) nounwind readnone
125 br label %test_maxnum.exit
126
127test_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
130 ret void
131}
132
133; ALL-LABEL: @minimum_test(
134; ALL: select
135define void @minimum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
136entry:
137 %cmp.i = fcmp olt float %a, 0.000000e+00
138 br i1 %cmp.i, label %test_minimum.exit, label %cond.else.i
139
140cond.else.i: ; preds = %entry
141 %0 = tail call float @llvm.minimum.f32(float %a, float %b) nounwind readnone
142 br label %test_minimum.exit
143
144test_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
147 ret void
148}
149
150; ALL-LABEL: @maximum_test(
151; ALL: select
152define void @maximum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
153entry:
154 %cmp.i = fcmp olt float %a, 0.000000e+00
155 br i1 %cmp.i, label %test_maximum.exit, label %cond.else.i
156
157cond.else.i: ; preds = %entry
158 %0 = tail call float @llvm.maximum.f32(float %a, float %b) nounwind readnone
159 br label %test_maximum.exit
160
161test_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
164 ret void
165}