]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Transforms/SimplifyCFG/speculate-math.ll
Vendor import of llvm trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / test / Transforms / SimplifyCFG / speculate-math.ll
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
3
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
12
13 ; ALL-LABEL: @fdiv_test(
14 ; EXPENSIVE: select i1 %cmp, double %div, double 0.0
15 ; CHEAP-NOT: select
16
17 define double @fdiv_test(double %a, double %b) {
18 entry:
19   %cmp = fcmp ogt double %a, 0.0
20   br i1 %cmp, label %cond.true, label %cond.end
21
22 cond.true:
23   %div = fdiv double %b, %a
24   br label %cond.end
25
26 cond.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
33 define void @sqrt_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind {
34 entry:
35   %cmp.i = fcmp olt float %a, 0.000000e+00
36   br i1 %cmp.i, label %test_sqrt.exit, label %cond.else.i
37
38 cond.else.i:                                      ; preds = %entry
39   %0 = tail call float @llvm.sqrt.f32(float %a) nounwind readnone
40   br label %test_sqrt.exit
41
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
45   ret void
46 }
47
48 ; ALL-LABEL: @fabs_test(
49 ; ALL: select
50 define void @fabs_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind {
51 entry:
52   %cmp.i = fcmp olt float %a, 0.000000e+00
53   br i1 %cmp.i, label %test_fabs.exit, label %cond.else.i
54
55 cond.else.i:                                      ; preds = %entry
56   %0 = tail call float @llvm.fabs.f32(float %a) nounwind readnone
57   br label %test_fabs.exit
58
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
62   ret void
63 }
64
65 ; ALL-LABEL: @fma_test(
66 ; ALL: select
67 define void @fma_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
68 entry:
69   %cmp.i = fcmp olt float %a, 0.000000e+00
70   br i1 %cmp.i, label %test_fma.exit, label %cond.else.i
71
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
75
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
79   ret void
80 }
81
82 ; ALL-LABEL: @fmuladd_test(
83 ; ALL: select
84 define void @fmuladd_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
85 entry:
86   %cmp.i = fcmp olt float %a, 0.000000e+00
87   br i1 %cmp.i, label %test_fmuladd.exit, label %cond.else.i
88
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
92
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
96   ret void
97 }
98
99 ; ALL-LABEL: @minnum_test(
100 ; ALL: select
101 define void @minnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
102 entry:
103   %cmp.i = fcmp olt float %a, 0.000000e+00
104   br i1 %cmp.i, label %test_minnum.exit, label %cond.else.i
105
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
109
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
113   ret void
114 }
115
116 ; ALL-LABEL: @maxnum_test(
117 ; ALL: select
118 define void @maxnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
119 entry:
120   %cmp.i = fcmp olt float %a, 0.000000e+00
121   br i1 %cmp.i, label %test_maxnum.exit, label %cond.else.i
122
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
126
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
130   ret void
131 }
132
133 ; ALL-LABEL: @minimum_test(
134 ; ALL: select
135 define void @minimum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
136 entry:
137   %cmp.i = fcmp olt float %a, 0.000000e+00
138   br i1 %cmp.i, label %test_minimum.exit, label %cond.else.i
139
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
143
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
147   ret void
148 }
149
150 ; ALL-LABEL: @maximum_test(
151 ; ALL: select
152 define void @maximum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
153 entry:
154   %cmp.i = fcmp olt float %a, 0.000000e+00
155   br i1 %cmp.i, label %test_maximum.exit, label %cond.else.i
156
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
160
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
164   ret void
165 }