1 ; RUN: llvm-as < %s | llvm-dis | FileCheck -strict-whitespace %s
2 ; RUN: opt -S < %s | FileCheck -strict-whitespace %s
3 ; RUN: verify-uselistorder %s
5 @addr = external global i64
6 @select = external global i1
7 @vec = external global <3 x float>
8 @arr = external global [3 x float]
10 declare float @foo(float)
12 define float @none(float %x, float %y) {
14 ; CHECK: %vec = load <3 x float>, ptr @vec
15 %vec = load <3 x float>, ptr @vec
16 ; CHECK: %select = load i1, ptr @select
17 %select = load i1, ptr @select
18 ; CHECK: %arr = load [3 x float], ptr @arr
19 %arr = load [3 x float], ptr @arr
20 ; CHECK: %scalable = load <vscale x 3 x float>, ptr @vec
21 %scalable = load <vscale x 3 x float>, ptr @vec
23 ; CHECK: %a = fadd float %x, %y
24 %a = fadd float %x, %y
25 ; CHECK: %a_vec = fadd <3 x float> %vec, %vec
26 %a_vec = fadd <3 x float> %vec, %vec
27 ; CHECK: %b = fsub float %x, %y
28 %b = fsub float %x, %y
29 ; CHECK: %b_vec = fsub <3 x float> %vec, %vec
30 %b_vec = fsub <3 x float> %vec, %vec
31 ; CHECK: %c = fmul float %x, %y
32 %c = fmul float %x, %y
33 ; CHECK: %c_vec = fmul <3 x float> %vec, %vec
34 %c_vec = fmul <3 x float> %vec, %vec
35 ; CHECK: %d = fdiv float %x, %y
36 %d = fdiv float %x, %y
37 ; CHECK: %d_vec = fdiv <3 x float> %vec, %vec
38 %d_vec = fdiv <3 x float> %vec, %vec
39 ; CHECK: %e = frem float %x, %y
40 %e = frem float %x, %y
41 ; CHECK: %e_vec = frem <3 x float> %vec, %vec
42 %e_vec = frem <3 x float> %vec, %vec
43 ; CHECK: %f = fneg float %x
45 ; CHECK: %f_vec = fneg <3 x float> %vec
46 %f_vec = fneg <3 x float> %vec
47 ; CHECK: %g = fpext float %x to double
48 %g = fpext float %x to double
49 ; CHECK: %g_vec = fpext <3 x float> %vec to <3 x double>
50 %g_vec = fpext <3 x float> %vec to <3 x double>
51 ; CHECK: %g_scalable = fpext <vscale x 3 x float> %scalable to <vscale x 3 x double>
52 %g_scalable = fpext <vscale x 3 x float> %scalable to <vscale x 3 x double>
53 ; CHECK: %h = fptrunc float %x to half
54 %h = fptrunc float %x to half
55 ; CHECK: %h_vec = fptrunc <3 x float> %vec to <3 x half>
56 %h_vec = fptrunc <3 x float> %vec to <3 x half>
57 ; CHECK: %h_scalable = fptrunc <vscale x 3 x float> %scalable to <vscale x 3 x half>
58 %h_scalable = fptrunc <vscale x 3 x float> %scalable to <vscale x 3 x half>
64 define float @no_nan(float %x, float %y) {
66 ; CHECK: %vec = load <3 x float>, ptr @vec
67 %vec = load <3 x float>, ptr @vec
68 ; CHECK: %select = load i1, ptr @select
69 %select = load i1, ptr @select
70 ; CHECK: %arr = load [3 x float], ptr @arr
71 %arr = load [3 x float], ptr @arr
72 ; CHECK: %scalable = load <vscale x 3 x float>, ptr @vec
73 %scalable = load <vscale x 3 x float>, ptr @vec
75 ; CHECK: %a = fadd nnan float %x, %y
76 %a = fadd nnan float %x, %y
77 ; CHECK: %a_vec = fadd nnan <3 x float> %vec, %vec
78 %a_vec = fadd nnan <3 x float> %vec, %vec
79 ; CHECK: %b = fsub nnan float %x, %y
80 %b = fsub nnan float %x, %y
81 ; CHECK: %b_vec = fsub nnan <3 x float> %vec, %vec
82 %b_vec = fsub nnan <3 x float> %vec, %vec
83 ; CHECK: %c = fmul nnan float %x, %y
84 %c = fmul nnan float %x, %y
85 ; CHECK: %c_vec = fmul nnan <3 x float> %vec, %vec
86 %c_vec = fmul nnan <3 x float> %vec, %vec
87 ; CHECK: %d = fdiv nnan float %x, %y
88 %d = fdiv nnan float %x, %y
89 ; CHECK: %d_vec = fdiv nnan <3 x float> %vec, %vec
90 %d_vec = fdiv nnan <3 x float> %vec, %vec
91 ; CHECK: %e = frem nnan float %x, %y
92 %e = frem nnan float %x, %y
93 ; CHECK: %e_vec = frem nnan <3 x float> %vec, %vec
94 %e_vec = frem nnan <3 x float> %vec, %vec
95 ; CHECK: %f = fneg nnan float %x
96 %f = fneg nnan float %x
97 ; CHECK: %f_vec = fneg nnan <3 x float> %vec
98 %f_vec = fneg nnan <3 x float> %vec
99 ; CHECK: %g = fpext nnan float %x to double
100 %g = fpext nnan float %x to double
101 ; CHECK: %g_vec = fpext nnan <3 x float> %vec to <3 x double>
102 %g_vec = fpext nnan <3 x float> %vec to <3 x double>
103 ; CHECK: %g_scalable = fpext nnan <vscale x 3 x float> %scalable to <vscale x 3 x double>
104 %g_scalable = fpext nnan <vscale x 3 x float> %scalable to <vscale x 3 x double>
105 ; CHECK: %h = fptrunc nnan float %x to half
106 %h = fptrunc nnan float %x to half
107 ; CHECK: %h_vec = fptrunc nnan <3 x float> %vec to <3 x half>
108 %h_vec = fptrunc nnan <3 x float> %vec to <3 x half>
109 ; CHECK: %h_scalable = fptrunc nnan <vscale x 3 x float> %scalable to <vscale x 3 x half>
110 %h_scalable = fptrunc nnan <vscale x 3 x float> %scalable to <vscale x 3 x half>
111 ; CHECK: ret float %f
116 define float @contract(float %x, float %y) {
118 ; CHECK: %a = fsub contract float %x, %y
119 %a = fsub contract float %x, %y
120 ; CHECK: %b = fadd contract float %x, %y
121 %b = fadd contract float %x, %y
122 ; CHECK: %c = fmul contract float %a, %b
123 %c = fmul contract float %a, %b
124 ; CHECK: %d = fpext contract float %x to double
125 %d = fpext contract float %x to double
126 ; CHECK: %e = fptrunc contract float %x to half
127 %e = fptrunc contract float %x to half
132 define float @reassoc(float %x, float %y) {
133 ; CHECK: %a = fsub reassoc float %x, %y
134 %a = fsub reassoc float %x, %y
135 ; CHECK: %b = fmul reassoc float %x, %y
136 %b = fmul reassoc float %x, %y
137 ; CHECK: %c = call reassoc float @foo(float %b)
138 %c = call reassoc float @foo(float %b)
139 ; CHECK: %d = fpext reassoc float %x to double
140 %d = fpext reassoc float %x to double
141 ; CHECK: %e = fptrunc reassoc float %x to half
142 %e = fptrunc reassoc float %x to half
147 define float @afn(float %x, float %y) {
148 ; CHECK: %a = fdiv afn float %x, %y
149 %a = fdiv afn float %x, %y
150 ; CHECK: %b = frem afn float %x, %y
151 %b = frem afn float %x, %y
152 ; CHECK: %c = call afn float @foo(float %b)
153 %c = call afn float @foo(float %b)
158 define float @no_nan_inf(float %x, float %y) {
160 ; CHECK: %vec = load <3 x float>, ptr @vec
161 %vec = load <3 x float>, ptr @vec
162 ; CHECK: %select = load i1, ptr @select
163 %select = load i1, ptr @select
164 ; CHECK: %arr = load [3 x float], ptr @arr
165 %arr = load [3 x float], ptr @arr
166 ; CHECK: %scalable = load <vscale x 3 x float>, ptr @vec
167 %scalable = load <vscale x 3 x float>, ptr @vec
169 ; CHECK: %a = fadd nnan ninf float %x, %y
170 %a = fadd ninf nnan float %x, %y
171 ; CHECK: %a_vec = fadd nnan <3 x float> %vec, %vec
172 %a_vec = fadd nnan <3 x float> %vec, %vec
173 ; CHECK: %b = fsub nnan float %x, %y
174 %b = fsub nnan float %x, %y
175 ; CHECK: %b_vec = fsub nnan ninf <3 x float> %vec, %vec
176 %b_vec = fsub ninf nnan <3 x float> %vec, %vec
177 ; CHECK: %c = fmul nnan float %x, %y
178 %c = fmul nnan float %x, %y
179 ; CHECK: %c_vec = fmul nnan <3 x float> %vec, %vec
180 %c_vec = fmul nnan <3 x float> %vec, %vec
181 ; CHECK: %d = fdiv nnan ninf float %x, %y
182 %d = fdiv ninf nnan float %x, %y
183 ; CHECK: %d_vec = fdiv nnan <3 x float> %vec, %vec
184 %d_vec = fdiv nnan <3 x float> %vec, %vec
185 ; CHECK: %e = frem nnan float %x, %y
186 %e = frem nnan float %x, %y
187 ; CHECK: %e_vec = frem nnan ninf <3 x float> %vec, %vec
188 %e_vec = frem ninf nnan <3 x float> %vec, %vec
189 ; CHECK: %f = fpext nnan ninf float %x to double
190 %f = fpext ninf nnan float %x to double
191 ; CHECK: %f_vec = fpext nnan ninf <3 x float> %vec to <3 x double>
192 %f_vec = fpext ninf nnan <3 x float> %vec to <3 x double>
193 ; CHECK: %f_scalable = fpext nnan ninf <vscale x 3 x float> %scalable to <vscale x 3 x double>
194 %f_scalable = fpext ninf nnan <vscale x 3 x float> %scalable to <vscale x 3 x double>
195 ; CHECK: %g = fptrunc nnan ninf float %x to half
196 %g = fptrunc ninf nnan float %x to half
197 ; CHECK: %g_vec = fptrunc nnan ninf <3 x float> %vec to <3 x half>
198 %g_vec = fptrunc ninf nnan <3 x float> %vec to <3 x half>
199 ; CHECK: %g_scalable = fptrunc nnan ninf <vscale x 3 x float> %scalable to <vscale x 3 x half>
200 %g_scalable = fptrunc ninf nnan <vscale x 3 x float> %scalable to <vscale x 3 x half>
201 ; CHECK: ret float %e
206 define float @mixed_flags(float %x, float %y) {
208 ; CHECK: %vec = load <3 x float>, ptr @vec
209 %vec = load <3 x float>, ptr @vec
210 ; CHECK: %select = load i1, ptr @select
211 %select = load i1, ptr @select
212 ; CHECK: %arr = load [3 x float], ptr @arr
213 %arr = load [3 x float], ptr @arr
215 ; CHECK: %a = fadd nnan ninf afn float %x, %y
216 %a = fadd ninf nnan afn float %x, %y
217 ; CHECK: %a_vec = fadd reassoc nnan <3 x float> %vec, %vec
218 %a_vec = fadd reassoc nnan <3 x float> %vec, %vec
219 ; CHECK: %b = fsub fast float %x, %y
220 %b = fsub nnan nsz fast float %x, %y
221 ; CHECK: %b_vec = fsub nnan <3 x float> %vec, %vec
222 %b_vec = fsub nnan <3 x float> %vec, %vec
223 ; CHECK: %c = fmul fast float %x, %y
224 %c = fmul nsz fast arcp float %x, %y
225 ; CHECK: %c_vec = fmul nsz <3 x float> %vec, %vec
226 %c_vec = fmul nsz <3 x float> %vec, %vec
227 ; CHECK: %d = fdiv nnan ninf arcp float %x, %y
228 %d = fdiv arcp ninf nnan float %x, %y
229 ; CHECK: %d_vec = fdiv fast <3 x float> %vec, %vec
230 %d_vec = fdiv fast nnan arcp <3 x float> %vec, %vec
231 ; CHECK: %e = frem nnan nsz float %x, %y
232 %e = frem nnan nsz float %x, %y
233 ; CHECK: %e_vec = frem nnan <3 x float> %vec, %vec
234 %e_vec = frem nnan <3 x float> %vec, %vec
235 ; CHECK: %f = fneg nnan nsz float %x
236 %f = fneg nnan nsz float %x
237 ; CHECK: %f_vec = fneg fast <3 x float> %vec
238 %f_vec = fneg fast <3 x float> %vec
239 ; CHECK: ret float %f
244 define float @fmf_calls(float %x, float %y) {
246 ; CHECK: %vec = load <3 x float>, ptr @vec
247 %vec = load <3 x float>, ptr @vec
248 ; CHECK: %select = load i1, ptr @select
249 %select = load i1, ptr @select
250 ; CHECK: %arr = load [3 x float], ptr @arr
251 %arr = load [3 x float], ptr @arr
253 ; CHECK: %a = call nnan ninf afn float @extfunc(float %x, float %y)
254 %a = call ninf nnan afn float @extfunc(float %x, float %y)
255 ; CHECK: %a_vec = call reassoc nnan <3 x float> @extfunc_vec(<3 x float> %vec, <3 x float> %vec)
256 %a_vec = call reassoc nnan <3 x float> @extfunc_vec(<3 x float> %vec, <3 x float> %vec)
257 ; CHECK: %b = call nnan ninf afn float (...) @var_extfunc(float %x, float %y)
258 %b = call ninf nnan afn float (...) @var_extfunc(float %x, float %y)
259 ; CHECK: %b_vec = call reassoc nnan <3 x float> (...) @var_extfunc_vec(<3 x float> %vec, <3 x float> %vec)
260 %b_vec = call reassoc nnan <3 x float> (...) @var_extfunc_vec(<3 x float> %vec, <3 x float> %vec)
261 ; CHECK: ret float %a
265 declare float @extfunc(float, float)
266 declare <3 x float> @extfunc_vec(<3 x float>, <3 x float>)
267 declare float @var_extfunc(...)
268 declare <3 x float> @var_extfunc_vec(...)