Mercurial > hg > CbC > CbC_llvm
comparison test/Transforms/InstCombine/minnum.ll @ 147:c2174574ed3a
LLVM 10
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 14 Aug 2019 16:55:33 +0900 |
parents | 60c9769439b8 |
children |
comparison
equal
deleted
inserted
replaced
134:3a76565eade5 | 147:c2174574ed3a |
---|---|
1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | |
1 ; RUN: opt -S -instcombine < %s | FileCheck %s | 2 ; RUN: opt -S -instcombine < %s | FileCheck %s |
2 | 3 |
3 declare float @llvm.minnum.f32(float, float) #0 | 4 declare float @llvm.minnum.f32(float, float) |
4 declare float @llvm.minnum.v2f32(<2 x float>, <2 x float>) #0 | 5 declare <2 x float> @llvm.minnum.v2f32(<2 x float>, <2 x float>) |
5 declare <4 x float> @llvm.minnum.v4f32(<4 x float>, <4 x float>) #0 | 6 declare <4 x float> @llvm.minnum.v4f32(<4 x float>, <4 x float>) |
6 | 7 |
7 declare double @llvm.minnum.f64(double, double) #0 | 8 declare double @llvm.minnum.f64(double, double) |
8 declare <2 x double> @llvm.minnum.v2f64(<2 x double>, <2 x double>) #0 | 9 declare <2 x double> @llvm.minnum.v2f64(<2 x double>, <2 x double>) |
9 | 10 |
10 declare float @llvm.maxnum.f32(float, float) #0 | 11 declare float @llvm.maxnum.f32(float, float) |
11 | 12 |
12 ; CHECK-LABEL: @constant_fold_minnum_f32 | 13 define float @constant_fold_minnum_f32() { |
13 ; CHECK-NEXT: ret float 1.000000e+00 | 14 ; CHECK-LABEL: @constant_fold_minnum_f32( |
14 define float @constant_fold_minnum_f32() #0 { | 15 ; CHECK-NEXT: ret float 1.000000e+00 |
15 %x = call float @llvm.minnum.f32(float 1.0, float 2.0) #0 | 16 ; |
16 ret float %x | 17 %x = call float @llvm.minnum.f32(float 1.0, float 2.0) |
17 } | 18 ret float %x |
18 | 19 } |
19 ; CHECK-LABEL: @constant_fold_minnum_f32_inv | 20 |
20 ; CHECK-NEXT: ret float 1.000000e+00 | 21 define float @constant_fold_minnum_f32_inv() { |
21 define float @constant_fold_minnum_f32_inv() #0 { | 22 ; CHECK-LABEL: @constant_fold_minnum_f32_inv( |
22 %x = call float @llvm.minnum.f32(float 2.0, float 1.0) #0 | 23 ; CHECK-NEXT: ret float 1.000000e+00 |
23 ret float %x | 24 ; |
24 } | 25 %x = call float @llvm.minnum.f32(float 2.0, float 1.0) |
25 | 26 ret float %x |
26 ; CHECK-LABEL: @constant_fold_minnum_f32_nan0 | 27 } |
27 ; CHECK-NEXT: ret float 2.000000e+00 | 28 |
28 define float @constant_fold_minnum_f32_nan0() #0 { | 29 define float @constant_fold_minnum_f32_nan0() { |
29 %x = call float @llvm.minnum.f32(float 0x7FF8000000000000, float 2.0) #0 | 30 ; CHECK-LABEL: @constant_fold_minnum_f32_nan0( |
30 ret float %x | 31 ; CHECK-NEXT: ret float 2.000000e+00 |
31 } | 32 ; |
32 | 33 %x = call float @llvm.minnum.f32(float 0x7FF8000000000000, float 2.0) |
33 ; CHECK-LABEL: @constant_fold_minnum_f32_nan1 | 34 ret float %x |
34 ; CHECK-NEXT: ret float 2.000000e+00 | 35 } |
35 define float @constant_fold_minnum_f32_nan1() #0 { | 36 |
36 %x = call float @llvm.minnum.f32(float 2.0, float 0x7FF8000000000000) #0 | 37 define float @constant_fold_minnum_f32_nan1() { |
37 ret float %x | 38 ; CHECK-LABEL: @constant_fold_minnum_f32_nan1( |
38 } | 39 ; CHECK-NEXT: ret float 2.000000e+00 |
39 | 40 ; |
40 ; CHECK-LABEL: @constant_fold_minnum_f32_nan_nan | 41 %x = call float @llvm.minnum.f32(float 2.0, float 0x7FF8000000000000) |
41 ; CHECK-NEXT: ret float 0x7FF8000000000000 | 42 ret float %x |
42 define float @constant_fold_minnum_f32_nan_nan() #0 { | 43 } |
43 %x = call float @llvm.minnum.f32(float 0x7FF8000000000000, float 0x7FF8000000000000) #0 | 44 |
44 ret float %x | 45 define float @constant_fold_minnum_f32_nan_nan() { |
45 } | 46 ; CHECK-LABEL: @constant_fold_minnum_f32_nan_nan( |
46 | 47 ; CHECK-NEXT: ret float 0x7FF8000000000000 |
47 ; CHECK-LABEL: @constant_fold_minnum_f32_p0_p0 | 48 ; |
48 ; CHECK-NEXT: ret float 0.000000e+00 | 49 %x = call float @llvm.minnum.f32(float 0x7FF8000000000000, float 0x7FF8000000000000) |
49 define float @constant_fold_minnum_f32_p0_p0() #0 { | 50 ret float %x |
50 %x = call float @llvm.minnum.f32(float 0.0, float 0.0) #0 | 51 } |
51 ret float %x | 52 |
52 } | 53 define float @constant_fold_minnum_f32_p0_p0() { |
53 | 54 ; CHECK-LABEL: @constant_fold_minnum_f32_p0_p0( |
54 ; CHECK-LABEL: @constant_fold_minnum_f32_p0_n0 | 55 ; CHECK-NEXT: ret float 0.000000e+00 |
55 ; CHECK-NEXT: ret float 0.000000e+00 | 56 ; |
56 define float @constant_fold_minnum_f32_p0_n0() #0 { | 57 %x = call float @llvm.minnum.f32(float 0.0, float 0.0) |
57 %x = call float @llvm.minnum.f32(float 0.0, float -0.0) #0 | 58 ret float %x |
58 ret float %x | 59 } |
59 } | 60 |
60 | 61 define float @constant_fold_minnum_f32_p0_n0() { |
61 ; CHECK-LABEL: @constant_fold_minnum_f32_n0_p0 | 62 ; CHECK-LABEL: @constant_fold_minnum_f32_p0_n0( |
62 ; CHECK-NEXT: ret float -0.000000e+00 | 63 ; CHECK-NEXT: ret float 0.000000e+00 |
63 define float @constant_fold_minnum_f32_n0_p0() #0 { | 64 ; |
64 %x = call float @llvm.minnum.f32(float -0.0, float 0.0) #0 | 65 %x = call float @llvm.minnum.f32(float 0.0, float -0.0) |
65 ret float %x | 66 ret float %x |
66 } | 67 } |
67 | 68 |
68 ; CHECK-LABEL: @constant_fold_minnum_f32_n0_n0 | 69 define float @constant_fold_minnum_f32_n0_p0() { |
69 ; CHECK-NEXT: ret float -0.000000e+00 | 70 ; CHECK-LABEL: @constant_fold_minnum_f32_n0_p0( |
70 define float @constant_fold_minnum_f32_n0_n0() #0 { | 71 ; CHECK-NEXT: ret float -0.000000e+00 |
71 %x = call float @llvm.minnum.f32(float -0.0, float -0.0) #0 | 72 ; |
72 ret float %x | 73 %x = call float @llvm.minnum.f32(float -0.0, float 0.0) |
73 } | 74 ret float %x |
74 | 75 } |
75 ; CHECK-LABEL: @constant_fold_minnum_v4f32 | 76 |
76 ; CHECK-NEXT: ret <4 x float> <float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 5.000000e+00> | 77 define float @constant_fold_minnum_f32_n0_n0() { |
77 define <4 x float> @constant_fold_minnum_v4f32() #0 { | 78 ; CHECK-LABEL: @constant_fold_minnum_f32_n0_n0( |
79 ; CHECK-NEXT: ret float -0.000000e+00 | |
80 ; | |
81 %x = call float @llvm.minnum.f32(float -0.0, float -0.0) | |
82 ret float %x | |
83 } | |
84 | |
85 define <4 x float> @constant_fold_minnum_v4f32() { | |
86 ; CHECK-LABEL: @constant_fold_minnum_v4f32( | |
87 ; CHECK-NEXT: ret <4 x float> <float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 5.000000e+00> | |
88 ; | |
78 %x = call <4 x float> @llvm.minnum.v4f32(<4 x float> <float 1.0, float 8.0, float 3.0, float 9.0>, <4 x float> <float 2.0, float 2.0, float 10.0, float 5.0>) | 89 %x = call <4 x float> @llvm.minnum.v4f32(<4 x float> <float 1.0, float 8.0, float 3.0, float 9.0>, <4 x float> <float 2.0, float 2.0, float 10.0, float 5.0>) |
79 ret <4 x float> %x | 90 ret <4 x float> %x |
80 } | 91 } |
81 | 92 |
82 ; CHECK-LABEL: @constant_fold_minnum_f64 | 93 define double @constant_fold_minnum_f64() { |
83 ; CHECK-NEXT: ret double 1.000000e+00 | 94 ; CHECK-LABEL: @constant_fold_minnum_f64( |
84 define double @constant_fold_minnum_f64() #0 { | 95 ; CHECK-NEXT: ret double 1.000000e+00 |
85 %x = call double @llvm.minnum.f64(double 1.0, double 2.0) #0 | 96 ; |
97 %x = call double @llvm.minnum.f64(double 1.0, double 2.0) | |
86 ret double %x | 98 ret double %x |
87 } | 99 } |
88 | 100 |
89 ; CHECK-LABEL: @constant_fold_minnum_f64_nan0 | 101 define double @constant_fold_minnum_f64_nan0() { |
90 ; CHECK-NEXT: ret double 2.000000e+00 | 102 ; CHECK-LABEL: @constant_fold_minnum_f64_nan0( |
91 define double @constant_fold_minnum_f64_nan0() #0 { | 103 ; CHECK-NEXT: ret double 2.000000e+00 |
92 %x = call double @llvm.minnum.f64(double 0x7FF8000000000000, double 2.0) #0 | 104 ; |
105 %x = call double @llvm.minnum.f64(double 0x7FF8000000000000, double 2.0) | |
93 ret double %x | 106 ret double %x |
94 } | 107 } |
95 | 108 |
96 ; CHECK-LABEL: @constant_fold_minnum_f64_nan1 | 109 define double @constant_fold_minnum_f64_nan1() { |
97 ; CHECK-NEXT: ret double 2.000000e+00 | 110 ; CHECK-LABEL: @constant_fold_minnum_f64_nan1( |
98 define double @constant_fold_minnum_f64_nan1() #0 { | 111 ; CHECK-NEXT: ret double 2.000000e+00 |
99 %x = call double @llvm.minnum.f64(double 2.0, double 0x7FF8000000000000) #0 | 112 ; |
113 %x = call double @llvm.minnum.f64(double 2.0, double 0x7FF8000000000000) | |
100 ret double %x | 114 ret double %x |
101 } | 115 } |
102 | 116 |
103 ; CHECK-LABEL: @constant_fold_minnum_f64_nan_nan | 117 define double @constant_fold_minnum_f64_nan_nan() { |
104 ; CHECK-NEXT: ret double 0x7FF8000000000000 | 118 ; CHECK-LABEL: @constant_fold_minnum_f64_nan_nan( |
105 define double @constant_fold_minnum_f64_nan_nan() #0 { | 119 ; CHECK-NEXT: ret double 0x7FF8000000000000 |
106 %x = call double @llvm.minnum.f64(double 0x7FF8000000000000, double 0x7FF8000000000000) #0 | 120 ; |
121 %x = call double @llvm.minnum.f64(double 0x7FF8000000000000, double 0x7FF8000000000000) | |
107 ret double %x | 122 ret double %x |
108 } | 123 } |
109 | 124 |
110 ; CHECK-LABEL: @canonicalize_constant_minnum_f32 | 125 define float @canonicalize_constant_minnum_f32(float %x) { |
111 ; CHECK: call float @llvm.minnum.f32(float %x, float 1.000000e+00) | 126 ; CHECK-LABEL: @canonicalize_constant_minnum_f32( |
112 define float @canonicalize_constant_minnum_f32(float %x) #0 { | 127 ; CHECK-NEXT: [[Y:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 1.000000e+00) |
113 %y = call float @llvm.minnum.f32(float 1.0, float %x) #0 | 128 ; CHECK-NEXT: ret float [[Y]] |
129 ; | |
130 %y = call float @llvm.minnum.f32(float 1.0, float %x) | |
114 ret float %y | 131 ret float %y |
115 } | 132 } |
116 | 133 |
117 ; CHECK-LABEL: @noop_minnum_f32 | 134 define float @minnum_f32_nan_val(float %x) { |
118 ; CHECK-NEXT: ret float %x | 135 ; CHECK-LABEL: @minnum_f32_nan_val( |
119 define float @noop_minnum_f32(float %x) #0 { | 136 ; CHECK-NEXT: ret float [[X:%.*]] |
120 %y = call float @llvm.minnum.f32(float %x, float %x) #0 | 137 ; |
138 %y = call float @llvm.minnum.f32(float 0x7FF8000000000000, float %x) | |
121 ret float %y | 139 ret float %y |
122 } | 140 } |
123 | 141 |
124 ; CHECK-LABEL: @minnum_f32_nan_val | 142 define float @minnum_f32_val_nan(float %x) { |
125 ; CHECK-NEXT: ret float %x | 143 ; CHECK-LABEL: @minnum_f32_val_nan( |
126 define float @minnum_f32_nan_val(float %x) #0 { | 144 ; CHECK-NEXT: ret float [[X:%.*]] |
127 %y = call float @llvm.minnum.f32(float 0x7FF8000000000000, float %x) #0 | 145 ; |
146 %y = call float @llvm.minnum.f32(float %x, float 0x7FF8000000000000) | |
128 ret float %y | 147 ret float %y |
129 } | 148 } |
130 | 149 |
131 ; CHECK-LABEL: @minnum_f32_val_nan | 150 define float @minnum_f32_1_minnum_val_p0(float %x) { |
132 ; CHECK-NEXT: ret float %x | 151 ; CHECK-LABEL: @minnum_f32_1_minnum_val_p0( |
133 define float @minnum_f32_val_nan(float %x) #0 { | 152 ; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 0.000000e+00) |
134 %y = call float @llvm.minnum.f32(float %x, float 0x7FF8000000000000) #0 | 153 ; CHECK-NEXT: ret float [[TMP1]] |
135 ret float %y | 154 ; |
136 } | 155 %y = call float @llvm.minnum.f32(float %x, float 0.0) |
137 | 156 %z = call float @llvm.minnum.f32(float %y, float 1.0) |
138 ; CHECK-LABEL: @fold_minnum_f32_undef_undef | 157 ret float %z |
139 ; CHECK-NEXT: ret float undef | 158 } |
140 define float @fold_minnum_f32_undef_undef(float %x) nounwind { | 159 |
141 %val = call float @llvm.minnum.f32(float undef, float undef) #0 | 160 define float @minnum_f32_1_minnum_p0_val_fast(float %x) { |
142 ret float %val | 161 ; CHECK-LABEL: @minnum_f32_1_minnum_p0_val_fast( |
143 } | 162 ; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.minnum.f32(float [[X:%.*]], float 0.000000e+00) |
144 | 163 ; CHECK-NEXT: ret float [[TMP1]] |
145 ; CHECK-LABEL: @fold_minnum_f32_val_undef | 164 ; |
146 ; CHECK-NEXT: ret float %x | 165 %y = call float @llvm.minnum.f32(float 0.0, float %x) |
147 define float @fold_minnum_f32_val_undef(float %x) nounwind { | 166 %z = call fast float @llvm.minnum.f32(float %y, float 1.0) |
148 %val = call float @llvm.minnum.f32(float %x, float undef) #0 | 167 ret float %z |
149 ret float %val | 168 } |
150 } | 169 |
151 | 170 define float @minnum_f32_1_minnum_p0_val_nnan_ninf(float %x) { |
152 ; CHECK-LABEL: @fold_minnum_f32_undef_val | 171 ; CHECK-LABEL: @minnum_f32_1_minnum_p0_val_nnan_ninf( |
153 ; CHECK-NEXT: ret float %x | 172 ; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf float @llvm.minnum.f32(float [[X:%.*]], float 0.000000e+00) |
154 define float @fold_minnum_f32_undef_val(float %x) nounwind { | 173 ; CHECK-NEXT: ret float [[TMP1]] |
155 %val = call float @llvm.minnum.f32(float undef, float %x) #0 | 174 ; |
156 ret float %val | 175 %y = call float @llvm.minnum.f32(float 0.0, float %x) |
157 } | 176 %z = call nnan ninf float @llvm.minnum.f32(float %y, float 1.0) |
158 | 177 ret float %z |
159 ; CHECK-LABEL: @minnum_x_minnum_x_y | 178 } |
160 ; CHECK-NEXT: call float @llvm.minnum.f32(float %x, float %y) | 179 |
161 ; CHECK-NEXT: ret float | 180 define float @minnum_f32_p0_minnum_val_n0(float %x) { |
162 define float @minnum_x_minnum_x_y(float %x, float %y) #0 { | 181 ; CHECK-LABEL: @minnum_f32_p0_minnum_val_n0( |
163 %a = call float @llvm.minnum.f32(float %x, float %y) #0 | 182 ; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 0.000000e+00) |
164 %b = call float @llvm.minnum.f32(float %x, float %a) #0 | 183 ; CHECK-NEXT: ret float [[TMP1]] |
184 ; | |
185 %y = call float @llvm.minnum.f32(float %x, float -0.0) | |
186 %z = call float @llvm.minnum.f32(float %y, float 0.0) | |
187 ret float %z | |
188 } | |
189 | |
190 define float @minnum_f32_1_minnum_p0_val(float %x) { | |
191 ; CHECK-LABEL: @minnum_f32_1_minnum_p0_val( | |
192 ; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 0.000000e+00) | |
193 ; CHECK-NEXT: ret float [[TMP1]] | |
194 ; | |
195 %y = call float @llvm.minnum.f32(float 0.0, float %x) | |
196 %z = call float @llvm.minnum.f32(float %y, float 1.0) | |
197 ret float %z | |
198 } | |
199 | |
200 define <2 x float> @minnum_f32_1_minnum_val_p0_val_v2f32(<2 x float> %x) { | |
201 ; CHECK-LABEL: @minnum_f32_1_minnum_val_p0_val_v2f32( | |
202 ; CHECK-NEXT: [[TMP1:%.*]] = call <2 x float> @llvm.minnum.v2f32(<2 x float> [[X:%.*]], <2 x float> zeroinitializer) | |
203 ; CHECK-NEXT: ret <2 x float> [[TMP1]] | |
204 ; | |
205 %y = call <2 x float> @llvm.minnum.v2f32(<2 x float> %x, <2 x float> zeroinitializer) | |
206 %z = call <2 x float> @llvm.minnum.v2f32(<2 x float> %y, <2 x float><float 1.0, float 1.0>) | |
207 ret <2 x float> %z | |
208 } | |
209 | |
210 define float @minnum4(float %x, float %y, float %z, float %w) { | |
211 ; CHECK-LABEL: @minnum4( | |
212 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]]) | |
213 ; CHECK-NEXT: [[B:%.*]] = call float @llvm.minnum.f32(float [[Z:%.*]], float [[W:%.*]]) | |
214 ; CHECK-NEXT: [[C:%.*]] = call float @llvm.minnum.f32(float [[A]], float [[B]]) | |
215 ; CHECK-NEXT: ret float [[C]] | |
216 ; | |
217 %a = call float @llvm.minnum.f32(float %x, float %y) | |
218 %b = call float @llvm.minnum.f32(float %z, float %w) | |
219 %c = call float @llvm.minnum.f32(float %a, float %b) | |
220 ret float %c | |
221 } | |
222 | |
223 define float @minnum_x_maxnum_x_y(float %x, float %y) { | |
224 ; CHECK-LABEL: @minnum_x_maxnum_x_y( | |
225 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float [[Y:%.*]]) | |
226 ; CHECK-NEXT: [[B:%.*]] = call float @llvm.minnum.f32(float [[X]], float [[A]]) | |
227 ; CHECK-NEXT: ret float [[B]] | |
228 ; | |
229 %a = call float @llvm.maxnum.f32(float %x, float %y) | |
230 %b = call float @llvm.minnum.f32(float %x, float %a) | |
165 ret float %b | 231 ret float %b |
166 } | 232 } |
167 | 233 |
168 ; CHECK-LABEL: @minnum_y_minnum_x_y | 234 define float @maxnum_x_minnum_x_y(float %x, float %y) { |
169 ; CHECK-NEXT: call float @llvm.minnum.f32(float %x, float %y) | 235 ; CHECK-LABEL: @maxnum_x_minnum_x_y( |
170 ; CHECK-NEXT: ret float | 236 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]]) |
171 define float @minnum_y_minnum_x_y(float %x, float %y) #0 { | 237 ; CHECK-NEXT: [[B:%.*]] = call float @llvm.maxnum.f32(float [[X]], float [[A]]) |
172 %a = call float @llvm.minnum.f32(float %x, float %y) #0 | 238 ; CHECK-NEXT: ret float [[B]] |
173 %b = call float @llvm.minnum.f32(float %y, float %a) #0 | 239 ; |
240 %a = call float @llvm.minnum.f32(float %x, float %y) | |
241 %b = call float @llvm.maxnum.f32(float %x, float %a) | |
174 ret float %b | 242 ret float %b |
175 } | 243 } |
176 | 244 |
177 ; CHECK-LABEL: @minnum_z_minnum_x_y | 245 ; PR37405 - https://bugs.llvm.org/show_bug.cgi?id=37405 |
178 ; CHECK-NEXT: call float @llvm.minnum.f32(float %x, float %y) | 246 |
179 ; CHECK-NEXT: call float @llvm.minnum.f32(float %z, float %a) | 247 define double @neg_neg(double %x, double %y) { |
180 ; CHECK-NEXT: ret float | 248 ; CHECK-LABEL: @neg_neg( |
181 define float @minnum_z_minnum_x_y(float %x, float %y, float %z) #0 { | 249 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double [[Y:%.*]]) |
182 %a = call float @llvm.minnum.f32(float %x, float %y) #0 | 250 ; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] |
183 %b = call float @llvm.minnum.f32(float %z, float %a) #0 | 251 ; CHECK-NEXT: ret double [[R]] |
184 ret float %b | 252 ; |
185 } | 253 %negx = fsub double -0.0, %x |
186 | 254 %negy = fsub double -0.0, %y |
187 ; CHECK-LABEL: @minnum_minnum_x_y_z | 255 %r = call double @llvm.minnum.f64(double %negx, double %negy) |
188 ; CHECK-NEXT: call float @llvm.minnum.f32(float %x, float %y) | 256 ret double %r |
189 ; CHECK-NEXT: call float @llvm.minnum.f32(float %a, float %z) | 257 } |
190 ; CHECK-NEXT: ret float | 258 |
191 define float @minnum_minnum_x_y_z(float %x, float %y, float %z) #0 { | 259 define double @unary_neg_neg(double %x, double %y) { |
192 %a = call float @llvm.minnum.f32(float %x, float %y) #0 | 260 ; CHECK-LABEL: @unary_neg_neg( |
193 %b = call float @llvm.minnum.f32(float %a, float %z) #0 | 261 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double [[Y:%.*]]) |
194 ret float %b | 262 ; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] |
195 } | 263 ; CHECK-NEXT: ret double [[R]] |
196 | 264 ; |
197 ; CHECK-LABEL: @minnum4 | 265 %negx = fneg double %x |
198 ; CHECK-NEXT: call float @llvm.minnum.f32(float %x, float %y) | 266 %negy = fneg double %y |
199 ; CHECK-NEXT: call float @llvm.minnum.f32(float %z, float %w) | 267 %r = call double @llvm.minnum.f64(double %negx, double %negy) |
200 ; CHECK-NEXT: call float @llvm.minnum.f32(float %a, float %b) | 268 ret double %r |
201 ; CHECK-NEXT: ret float | 269 } |
202 define float @minnum4(float %x, float %y, float %z, float %w) #0 { | 270 |
203 %a = call float @llvm.minnum.f32(float %x, float %y) #0 | 271 ; FMF is not required, but it should be propagated from the intrinsic (not the fnegs). |
204 %b = call float @llvm.minnum.f32(float %z, float %w) #0 | 272 ; Also, make sure this works with vectors. |
205 %c = call float @llvm.minnum.f32(float %a, float %b) #0 | 273 |
206 ret float %c | 274 define <2 x double> @neg_neg_vec_fmf(<2 x double> %x, <2 x double> %y) { |
207 } | 275 ; CHECK-LABEL: @neg_neg_vec_fmf( |
208 | 276 ; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf <2 x double> @llvm.maxnum.v2f64(<2 x double> [[X:%.*]], <2 x double> [[Y:%.*]]) |
209 ; CHECK-LABEL: @minnum_x_maxnum_x_y | 277 ; CHECK-NEXT: [[R:%.*]] = fsub nnan ninf <2 x double> <double -0.000000e+00, double -0.000000e+00>, [[TMP1]] |
210 ; CHECK-NEXT: call float @llvm.maxnum.f32 | 278 ; CHECK-NEXT: ret <2 x double> [[R]] |
211 ; CHECK-NEXT: call float @llvm.minnum.f32 | 279 ; |
212 ; CHECK-NEXT: ret float | 280 %negx = fsub reassoc <2 x double> <double -0.0, double -0.0>, %x |
213 define float @minnum_x_maxnum_x_y(float %x, float %y) #0 { | 281 %negy = fsub fast <2 x double> <double -0.0, double -0.0>, %y |
214 %a = call float @llvm.maxnum.f32(float %x, float %y) #0 | 282 %r = call nnan ninf <2 x double> @llvm.minnum.v2f64(<2 x double> %negx, <2 x double> %negy) |
215 %b = call float @llvm.minnum.f32(float %x, float %a) #0 | 283 ret <2 x double> %r |
216 ret float %b | 284 } |
217 } | 285 |
218 | 286 define <2 x double> @unary_neg_neg_vec_fmf(<2 x double> %x, <2 x double> %y) { |
219 ; CHECK-LABEL: @maxnum_x_minnum_x_y | 287 ; CHECK-LABEL: @unary_neg_neg_vec_fmf( |
220 ; CHECK-NEXT: call float @llvm.minnum.f32 | 288 ; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf <2 x double> @llvm.maxnum.v2f64(<2 x double> [[X:%.*]], <2 x double> [[Y:%.*]]) |
221 ; CHECK-NEXT: call float @llvm.maxnum.f32 | 289 ; CHECK-NEXT: [[R:%.*]] = fsub nnan ninf <2 x double> <double -0.000000e+00, double -0.000000e+00>, [[TMP1]] |
222 ; CHECK-NEXT: ret float | 290 ; CHECK-NEXT: ret <2 x double> [[R]] |
223 define float @maxnum_x_minnum_x_y(float %x, float %y) #0 { | 291 ; |
224 %a = call float @llvm.minnum.f32(float %x, float %y) #0 | 292 %negx = fneg reassoc <2 x double> %x |
225 %b = call float @llvm.maxnum.f32(float %x, float %a) #0 | 293 %negy = fneg fast <2 x double> %y |
226 ret float %b | 294 %r = call nnan ninf <2 x double> @llvm.minnum.v2f64(<2 x double> %negx, <2 x double> %negy) |
227 } | 295 ret <2 x double> %r |
228 | 296 } |
229 ; CHECK-LABEL: @fold_minnum_f32_inf_val | 297 |
230 ; CHECK-NEXT: call float @llvm.minnum.f32(float %x, float 0x7FF0000000000000) | 298 ; 1 extra use of an intermediate value should still allow the fold, |
231 ; CHECK-NEXT: ret float | 299 ; but 2 would require more instructions than we started with. |
232 define float @fold_minnum_f32_inf_val(float %x) nounwind { | 300 |
233 %val = call float @llvm.minnum.f32(float 0x7FF0000000000000, float %x) #0 | 301 declare void @use(double) |
234 ret float %val | 302 define double @neg_neg_extra_use_x(double %x, double %y) { |
235 } | 303 ; CHECK-LABEL: @neg_neg_extra_use_x( |
236 | 304 ; CHECK-NEXT: [[NEGX:%.*]] = fsub double -0.000000e+00, [[X:%.*]] |
237 ; CHECK-LABEL: @fold_minnum_f32_minf_val | 305 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X]], double [[Y:%.*]]) |
238 ; CHECK-NEXT: ret float 0xFFF0000000000000 | 306 ; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] |
239 define float @fold_minnum_f32_minf_val(float %x) nounwind { | 307 ; CHECK-NEXT: call void @use(double [[NEGX]]) |
240 %val = call float @llvm.minnum.f32(float 0xFFF0000000000000, float %x) #0 | 308 ; CHECK-NEXT: ret double [[R]] |
241 ret float %val | 309 ; |
242 } | 310 %negx = fsub double -0.0, %x |
243 | 311 %negy = fsub double -0.0, %y |
244 attributes #0 = { nounwind readnone } | 312 %r = call double @llvm.minnum.f64(double %negx, double %negy) |
313 call void @use(double %negx) | |
314 ret double %r | |
315 } | |
316 | |
317 define double @unary_neg_neg_extra_use_x(double %x, double %y) { | |
318 ; CHECK-LABEL: @unary_neg_neg_extra_use_x( | |
319 ; CHECK-NEXT: [[NEGX:%.*]] = fneg double [[X:%.*]] | |
320 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X]], double [[Y:%.*]]) | |
321 ; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] | |
322 ; CHECK-NEXT: call void @use(double [[NEGX]]) | |
323 ; CHECK-NEXT: ret double [[R]] | |
324 ; | |
325 %negx = fneg double %x | |
326 %negy = fneg double %y | |
327 %r = call double @llvm.minnum.f64(double %negx, double %negy) | |
328 call void @use(double %negx) | |
329 ret double %r | |
330 } | |
331 | |
332 define double @neg_neg_extra_use_y(double %x, double %y) { | |
333 ; CHECK-LABEL: @neg_neg_extra_use_y( | |
334 ; CHECK-NEXT: [[NEGY:%.*]] = fsub double -0.000000e+00, [[Y:%.*]] | |
335 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double [[Y]]) | |
336 ; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] | |
337 ; CHECK-NEXT: call void @use(double [[NEGY]]) | |
338 ; CHECK-NEXT: ret double [[R]] | |
339 ; | |
340 %negx = fsub double -0.0, %x | |
341 %negy = fsub double -0.0, %y | |
342 %r = call double @llvm.minnum.f64(double %negx, double %negy) | |
343 call void @use(double %negy) | |
344 ret double %r | |
345 } | |
346 | |
347 define double @unary_neg_neg_extra_use_y(double %x, double %y) { | |
348 ; CHECK-LABEL: @unary_neg_neg_extra_use_y( | |
349 ; CHECK-NEXT: [[NEGY:%.*]] = fneg double [[Y:%.*]] | |
350 ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double [[Y]]) | |
351 ; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] | |
352 ; CHECK-NEXT: call void @use(double [[NEGY]]) | |
353 ; CHECK-NEXT: ret double [[R]] | |
354 ; | |
355 %negx = fneg double %x | |
356 %negy = fneg double %y | |
357 %r = call double @llvm.minnum.f64(double %negx, double %negy) | |
358 call void @use(double %negy) | |
359 ret double %r | |
360 } | |
361 | |
362 define double @neg_neg_extra_use_x_and_y(double %x, double %y) { | |
363 ; CHECK-LABEL: @neg_neg_extra_use_x_and_y( | |
364 ; CHECK-NEXT: [[NEGX:%.*]] = fsub double -0.000000e+00, [[X:%.*]] | |
365 ; CHECK-NEXT: [[NEGY:%.*]] = fsub double -0.000000e+00, [[Y:%.*]] | |
366 ; CHECK-NEXT: [[R:%.*]] = call double @llvm.minnum.f64(double [[NEGX]], double [[NEGY]]) | |
367 ; CHECK-NEXT: call void @use(double [[NEGX]]) | |
368 ; CHECK-NEXT: call void @use(double [[NEGY]]) | |
369 ; CHECK-NEXT: ret double [[R]] | |
370 ; | |
371 %negx = fsub double -0.0, %x | |
372 %negy = fsub double -0.0, %y | |
373 %r = call double @llvm.minnum.f64(double %negx, double %negy) | |
374 call void @use(double %negx) | |
375 call void @use(double %negy) | |
376 ret double %r | |
377 } | |
378 | |
379 define double @unary_neg_neg_extra_use_x_and_y(double %x, double %y) { | |
380 ; CHECK-LABEL: @unary_neg_neg_extra_use_x_and_y( | |
381 ; CHECK-NEXT: [[NEGX:%.*]] = fneg double [[X:%.*]] | |
382 ; CHECK-NEXT: [[NEGY:%.*]] = fneg double [[Y:%.*]] | |
383 ; CHECK-NEXT: [[R:%.*]] = call double @llvm.minnum.f64(double [[NEGX]], double [[NEGY]]) | |
384 ; CHECK-NEXT: call void @use(double [[NEGX]]) | |
385 ; CHECK-NEXT: call void @use(double [[NEGY]]) | |
386 ; CHECK-NEXT: ret double [[R]] | |
387 ; | |
388 %negx = fneg double %x | |
389 %negy = fneg double %y | |
390 %r = call double @llvm.minnum.f64(double %negx, double %negy) | |
391 call void @use(double %negx) | |
392 call void @use(double %negy) | |
393 ret double %r | |
394 } | |
395 |