llvm-project
218 строк · 7.4 Кб
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
4
5@addr = external global i64
6@select = external global i1
7@vec = external global <3 x float>
8@arr = external global [3 x float]
9
10declare float @foo(float)
11
12define float @none(float %x, float %y) {
13entry:
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
21; CHECK: %a = fadd float %x, %y
22%a = fadd float %x, %y
23; CHECK: %a_vec = fadd <3 x float> %vec, %vec
24%a_vec = fadd <3 x float> %vec, %vec
25; CHECK: %b = fsub float %x, %y
26%b = fsub float %x, %y
27; CHECK: %b_vec = fsub <3 x float> %vec, %vec
28%b_vec = fsub <3 x float> %vec, %vec
29; CHECK: %c = fmul float %x, %y
30%c = fmul float %x, %y
31; CHECK: %c_vec = fmul <3 x float> %vec, %vec
32%c_vec = fmul <3 x float> %vec, %vec
33; CHECK: %d = fdiv float %x, %y
34%d = fdiv float %x, %y
35; CHECK: %d_vec = fdiv <3 x float> %vec, %vec
36%d_vec = fdiv <3 x float> %vec, %vec
37; CHECK: %e = frem float %x, %y
38%e = frem float %x, %y
39; CHECK: %e_vec = frem <3 x float> %vec, %vec
40%e_vec = frem <3 x float> %vec, %vec
41; CHECK: %f = fneg float %x
42%f = fneg float %x
43; CHECK: %f_vec = fneg <3 x float> %vec
44%f_vec = fneg <3 x float> %vec
45; CHECK: ret float %f
46ret float %f
47}
48
49; CHECK: no_nan
50define float @no_nan(float %x, float %y) {
51entry:
52; CHECK: %vec = load <3 x float>, ptr @vec
53%vec = load <3 x float>, ptr @vec
54; CHECK: %select = load i1, ptr @select
55%select = load i1, ptr @select
56; CHECK: %arr = load [3 x float], ptr @arr
57%arr = load [3 x float], ptr @arr
58
59; CHECK: %a = fadd nnan float %x, %y
60%a = fadd nnan float %x, %y
61; CHECK: %a_vec = fadd nnan <3 x float> %vec, %vec
62%a_vec = fadd nnan <3 x float> %vec, %vec
63; CHECK: %b = fsub nnan float %x, %y
64%b = fsub nnan float %x, %y
65; CHECK: %b_vec = fsub nnan <3 x float> %vec, %vec
66%b_vec = fsub nnan <3 x float> %vec, %vec
67; CHECK: %c = fmul nnan float %x, %y
68%c = fmul nnan float %x, %y
69; CHECK: %c_vec = fmul nnan <3 x float> %vec, %vec
70%c_vec = fmul nnan <3 x float> %vec, %vec
71; CHECK: %d = fdiv nnan float %x, %y
72%d = fdiv nnan float %x, %y
73; CHECK: %d_vec = fdiv nnan <3 x float> %vec, %vec
74%d_vec = fdiv nnan <3 x float> %vec, %vec
75; CHECK: %e = frem nnan float %x, %y
76%e = frem nnan float %x, %y
77; CHECK: %e_vec = frem nnan <3 x float> %vec, %vec
78%e_vec = frem nnan <3 x float> %vec, %vec
79; CHECK: %f = fneg nnan float %x
80%f = fneg nnan float %x
81; CHECK: %f_vec = fneg nnan <3 x float> %vec
82%f_vec = fneg nnan <3 x float> %vec
83; CHECK: ret float %f
84ret float %f
85}
86
87; CHECK: @contract(
88define float @contract(float %x, float %y) {
89entry:
90; CHECK: %a = fsub contract float %x, %y
91%a = fsub contract float %x, %y
92; CHECK: %b = fadd contract float %x, %y
93%b = fadd contract float %x, %y
94; CHECK: %c = fmul contract float %a, %b
95%c = fmul contract float %a, %b
96ret float %c
97}
98
99; CHECK: @reassoc(
100define float @reassoc(float %x, float %y) {
101; CHECK: %a = fsub reassoc float %x, %y
102%a = fsub reassoc float %x, %y
103; CHECK: %b = fmul reassoc float %x, %y
104%b = fmul reassoc float %x, %y
105; CHECK: %c = call reassoc float @foo(float %b)
106%c = call reassoc float @foo(float %b)
107ret float %c
108}
109
110; CHECK: @afn(
111define float @afn(float %x, float %y) {
112; CHECK: %a = fdiv afn float %x, %y
113%a = fdiv afn float %x, %y
114; CHECK: %b = frem afn float %x, %y
115%b = frem afn float %x, %y
116; CHECK: %c = call afn float @foo(float %b)
117%c = call afn float @foo(float %b)
118ret float %c
119}
120
121; CHECK: no_nan_inf
122define float @no_nan_inf(float %x, float %y) {
123entry:
124; CHECK: %vec = load <3 x float>, ptr @vec
125%vec = load <3 x float>, ptr @vec
126; CHECK: %select = load i1, ptr @select
127%select = load i1, ptr @select
128; CHECK: %arr = load [3 x float], ptr @arr
129%arr = load [3 x float], ptr @arr
130
131; CHECK: %a = fadd nnan ninf float %x, %y
132%a = fadd ninf nnan float %x, %y
133; CHECK: %a_vec = fadd nnan <3 x float> %vec, %vec
134%a_vec = fadd nnan <3 x float> %vec, %vec
135; CHECK: %b = fsub nnan float %x, %y
136%b = fsub nnan float %x, %y
137; CHECK: %b_vec = fsub nnan ninf <3 x float> %vec, %vec
138%b_vec = fsub ninf nnan <3 x float> %vec, %vec
139; CHECK: %c = fmul nnan float %x, %y
140%c = fmul nnan float %x, %y
141; CHECK: %c_vec = fmul nnan <3 x float> %vec, %vec
142%c_vec = fmul nnan <3 x float> %vec, %vec
143; CHECK: %d = fdiv nnan ninf float %x, %y
144%d = fdiv ninf nnan float %x, %y
145; CHECK: %d_vec = fdiv nnan <3 x float> %vec, %vec
146%d_vec = fdiv nnan <3 x float> %vec, %vec
147; CHECK: %e = frem nnan float %x, %y
148%e = frem nnan float %x, %y
149; CHECK: %e_vec = frem nnan ninf <3 x float> %vec, %vec
150%e_vec = frem ninf nnan <3 x float> %vec, %vec
151; CHECK: ret float %e
152ret float %e
153}
154
155; CHECK: mixed_flags
156define float @mixed_flags(float %x, float %y) {
157entry:
158; CHECK: %vec = load <3 x float>, ptr @vec
159%vec = load <3 x float>, ptr @vec
160; CHECK: %select = load i1, ptr @select
161%select = load i1, ptr @select
162; CHECK: %arr = load [3 x float], ptr @arr
163%arr = load [3 x float], ptr @arr
164
165; CHECK: %a = fadd nnan ninf afn float %x, %y
166%a = fadd ninf nnan afn float %x, %y
167; CHECK: %a_vec = fadd reassoc nnan <3 x float> %vec, %vec
168%a_vec = fadd reassoc nnan <3 x float> %vec, %vec
169; CHECK: %b = fsub fast float %x, %y
170%b = fsub nnan nsz fast float %x, %y
171; CHECK: %b_vec = fsub nnan <3 x float> %vec, %vec
172%b_vec = fsub nnan <3 x float> %vec, %vec
173; CHECK: %c = fmul fast float %x, %y
174%c = fmul nsz fast arcp float %x, %y
175; CHECK: %c_vec = fmul nsz <3 x float> %vec, %vec
176%c_vec = fmul nsz <3 x float> %vec, %vec
177; CHECK: %d = fdiv nnan ninf arcp float %x, %y
178%d = fdiv arcp ninf nnan float %x, %y
179; CHECK: %d_vec = fdiv fast <3 x float> %vec, %vec
180%d_vec = fdiv fast nnan arcp <3 x float> %vec, %vec
181; CHECK: %e = frem nnan nsz float %x, %y
182%e = frem nnan nsz float %x, %y
183; CHECK: %e_vec = frem nnan <3 x float> %vec, %vec
184%e_vec = frem nnan <3 x float> %vec, %vec
185; CHECK: %f = fneg nnan nsz float %x
186%f = fneg nnan nsz float %x
187; CHECK: %f_vec = fneg fast <3 x float> %vec
188%f_vec = fneg fast <3 x float> %vec
189; CHECK: ret float %f
190ret float %f
191}
192
193; CHECK: @fmf_calls(
194define float @fmf_calls(float %x, float %y) {
195entry:
196; CHECK: %vec = load <3 x float>, ptr @vec
197%vec = load <3 x float>, ptr @vec
198; CHECK: %select = load i1, ptr @select
199%select = load i1, ptr @select
200; CHECK: %arr = load [3 x float], ptr @arr
201%arr = load [3 x float], ptr @arr
202
203; CHECK: %a = call nnan ninf afn float @extfunc(float %x, float %y)
204%a = call ninf nnan afn float @extfunc(float %x, float %y)
205; CHECK: %a_vec = call reassoc nnan <3 x float> @extfunc_vec(<3 x float> %vec, <3 x float> %vec)
206%a_vec = call reassoc nnan <3 x float> @extfunc_vec(<3 x float> %vec, <3 x float> %vec)
207; CHECK: %b = call nnan ninf afn float (...) @var_extfunc(float %x, float %y)
208%b = call ninf nnan afn float (...) @var_extfunc(float %x, float %y)
209; CHECK: %b_vec = call reassoc nnan <3 x float> (...) @var_extfunc_vec(<3 x float> %vec, <3 x float> %vec)
210%b_vec = call reassoc nnan <3 x float> (...) @var_extfunc_vec(<3 x float> %vec, <3 x float> %vec)
211; CHECK: ret float %a
212ret float %a
213}
214
215declare float @extfunc(float, float)
216declare <3 x float> @extfunc_vec(<3 x float>, <3 x float>)
217declare float @var_extfunc(...)
218declare <3 x float> @var_extfunc_vec(...)
219