[AMDGPU] Test codegen'ing True16 additions.
[llvm-project.git] / flang / test / Lower / math-lowering.f90
blob973cbcfd366b790241ab215c9e09645d6c6466eb
1 ! RUN: split-file %s %t
3 //--- abs.f90
4 ! RUN: bbc -emit-fir %t/abs.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/abs.f90
5 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/abs.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/abs.f90
6 ! RUN: bbc -emit-fir %t/abs.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/abs.f90
7 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/abs.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/abs.f90
8 ! RUN: bbc -emit-fir %t/abs.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/abs.f90
9 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/abs.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/abs.f90
11 function test_real4(x)
12 real :: x, test_real4
13 test_real4 = abs(x)
14 end function
16 ! ALL-LABEL: @_QPtest_real4
17 ! FAST: {{%[A-Za-z0-9._]+}} = math.absf {{%[A-Za-z0-9._]+}} {{.*}}: f32
18 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.absf {{%[A-Za-z0-9._]+}} {{.*}}: f32
19 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @fabsf({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> f32
21 function test_real8(x)
22 real(8) :: x, test_real8
23 test_real8 = abs(x)
24 end function
26 ! ALL-LABEL: @_QPtest_real8
27 ! FAST: {{%[A-Za-z0-9._]+}} = math.absf {{%[A-Za-z0-9._]+}} {{.*}}: f64
28 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.absf {{%[A-Za-z0-9._]+}} {{.*}}: f64
29 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @fabs({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> f64
31 function test_real16(x)
32 real(16) :: x, test_real16
33 test_real16 = abs(x)
34 end function
35 ! ALL-LABEL: @_QPtest_real16
36 ! FAST: {{%[A-Za-z0-9._]+}} = math.absf {{%[A-Za-z0-9._]+}} {{.*}}: f128
37 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.absf {{%[A-Za-z0-9._]+}} {{.*}}: f128
38 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.fabs.f128({{%[A-Za-z0-9._]+}}) {{.*}}: (f128) -> f128
40 function test_complex4(c)
41 complex(4) :: c, test_complex4
42 test_complex4 = abs(c)
43 end function
44 ! ALL-LABEL: @_QPtest_complex4
45 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @cabsf({{%[A-Za-z0-9._]+}}) {{.*}}: (!fir.complex<4>) -> f32
47 function test_complex8(c)
48 complex(8) :: c, test_complex8
49 test_complex8 = abs(c)
50 end function
51 ! ALL-LABEL: @_QPtest_complex8
52 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @cabs({{%[A-Za-z0-9._]+}}) {{.*}}: (!fir.complex<8>) -> f64
54 ! PRECISE-DAG: func.func private @fabsf(f32) -> f32 attributes {fir.bindc_name = "fabsf", fir.runtime}
55 ! PRECISE-DAG: func.func private @fabs(f64) -> f64 attributes {fir.bindc_name = "fabs", fir.runtime}
56 ! PRECISE-DAG: func.func private @llvm.fabs.f128(f128) -> f128 attributes {fir.bindc_name = "llvm.fabs.f128", fir.runtime}
57 ! PRECISE-DAG: func.func private @cabsf(!fir.complex<4>) -> f32 attributes {fir.bindc_name = "cabsf", fir.runtime}
58 ! PRECISE-DAG: func.func private @cabs(!fir.complex<8>) -> f64 attributes {fir.bindc_name = "cabs", fir.runtime}
60 //--- aint.f90
61 ! RUN: bbc -emit-fir %t/aint.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL %t/aint.f90
62 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/aint.f90 -o - | FileCheck --check-prefixes=ALL %t/aint.f90
63 ! RUN: bbc -emit-fir %t/aint.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL %t/aint.f90
64 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/aint.f90 -o - | FileCheck --check-prefixes=ALL %t/aint.f90
65 ! RUN: bbc -emit-fir %t/aint.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL %t/aint.f90
66 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/aint.f90 -o - | FileCheck --check-prefixes=ALL %t/aint.f90
68 function test_real4(x)
69 real :: x, test_real4
70 test_real4 = aint(x)
71 end function
73 ! ALL-LABEL: @_QPtest_real4
74 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.trunc.f32({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> f32
76 function test_real8(x)
77 real(8) :: x, test_real8
78 test_real8 = aint(x)
79 end function
81 ! ALL-LABEL: @_QPtest_real8
82 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.trunc.f64({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> f64
84 function test_real10(x)
85 real(10) :: x, test_real10
86 test_real10 = aint(x)
87 end function
89 ! ALL-LABEL: @_QPtest_real10
90 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.trunc.f80({{%[A-Za-z0-9._]+}}) {{.*}}: (f80) -> f80
92 ! TODO: wait until fp128 is supported well in llvm.trunc
93 !function test_real16(x)
94 ! real(16) :: x, test_real16
95 ! test_real16 = aint(x)
96 !end function
98 ! ALL-DAG: func.func private @llvm.trunc.f32(f32) -> f32 attributes {fir.bindc_name = "llvm.trunc.f32", fir.runtime}
99 ! ALL-DAG: func.func private @llvm.trunc.f64(f64) -> f64 attributes {fir.bindc_name = "llvm.trunc.f64", fir.runtime}
100 ! ALL-DAG: func.func private @llvm.trunc.f80(f80) -> f80 attributes {fir.bindc_name = "llvm.trunc.f80", fir.runtime}
102 //--- anint.f90
103 ! RUN: bbc -emit-fir %t/anint.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/anint.f90
104 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/anint.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/anint.f90
105 ! RUN: bbc -emit-fir %t/anint.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/anint.f90
106 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/anint.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/anint.f90
107 ! RUN: bbc -emit-fir %t/anint.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/anint.f90
108 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/anint.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/anint.f90
110 function test_real4(x)
111 real :: x, test_real4
112 test_real4 = anint(x)
113 end function
115 ! ALL-LABEL: @_QPtest_real4
116 ! FAST: {{%[A-Za-z0-9._]+}} = llvm.intr.round({{%[A-Za-z0-9._]+}}) : (f32) -> f32
117 ! RELAXED: {{%[A-Za-z0-9._]+}} = llvm.intr.round({{%[A-Za-z0-9._]+}}) : (f32) -> f32
118 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.round.f32({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> f32
120 function test_real8(x)
121 real(8) :: x, test_real8
122 test_real8 = anint(x)
123 end function
125 ! ALL-LABEL: @_QPtest_real8
126 ! FAST: {{%[A-Za-z0-9._]+}} = llvm.intr.round({{%[A-Za-z0-9._]+}}) : (f64) -> f64
127 ! RELAXED: {{%[A-Za-z0-9._]+}} = llvm.intr.round({{%[A-Za-z0-9._]+}}) : (f64) -> f64
128 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.round.f64({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> f64
130 function test_real10(x)
131 real(10) :: x, test_real10
132 test_real10 = anint(x)
133 end function
135 ! ALL-LABEL: @_QPtest_real10
136 ! FAST: {{%[A-Za-z0-9._]+}} = llvm.intr.round({{%[A-Za-z0-9._]+}}) : (f80) -> f80
137 ! RELAXED: {{%[A-Za-z0-9._]+}} = llvm.intr.round({{%[A-Za-z0-9._]+}}) : (f80) -> f80
138 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.round.f80({{%[A-Za-z0-9._]+}}) {{.*}}: (f80) -> f80
140 ! TODO: wait until fp128 is supported well in llvm.round
141 !function test_real16(x)
142 ! real(16) :: x, test_real16
143 ! test_real16 = anint(x)
144 !end function
146 ! PRECISE-DAG: func.func private @llvm.round.f32(f32) -> f32 attributes {fir.bindc_name = "llvm.round.f32", fir.runtime}
147 ! PRECISE-DAG: func.func private @llvm.round.f64(f64) -> f64 attributes {fir.bindc_name = "llvm.round.f64", fir.runtime}
148 ! PRECISE-DAG: func.func private @llvm.round.f80(f80) -> f80 attributes {fir.bindc_name = "llvm.round.f80", fir.runtime}
150 //--- atan.f90
151 ! RUN: bbc -emit-fir %t/atan.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/atan.f90
152 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/atan.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/atan.f90
153 ! RUN: bbc -emit-fir %t/atan.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/atan.f90
154 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/atan.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/atan.f90
155 ! RUN: bbc -emit-fir %t/atan.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/atan.f90
156 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/atan.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/atan.f90
158 function test_real4(x)
159 real :: x, test_real4
160 test_real4 = atan(x)
161 end function
163 ! ALL-LABEL: @_QPtest_real4
164 ! FAST: {{%[A-Za-z0-9._]+}} = math.atan {{%[A-Za-z0-9._]+}} {{.*}}: f32
165 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.atan {{%[A-Za-z0-9._]+}} {{.*}}: f32
166 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @atanf({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> f32
168 function test_real8(x)
169 real(8) :: x, test_real8
170 test_real8 = atan(x)
171 end function
173 ! ALL-LABEL: @_QPtest_real8
174 ! FAST: {{%[A-Za-z0-9._]+}} = math.atan {{%[A-Za-z0-9._]+}} {{.*}}: f64
175 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.atan {{%[A-Za-z0-9._]+}} {{.*}}: f64
176 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @atan({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> f64
178 ! PRECISE-DAG: func.func private @atanf(f32) -> f32 attributes {fir.bindc_name = "atanf", fir.runtime}
179 ! PRECISE-DAG: func.func private @atan(f64) -> f64 attributes {fir.bindc_name = "atan", fir.runtime}
181 //--- atan2.f90
182 ! RUN: bbc -emit-fir %t/atan2.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/atan2.f90
183 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/atan2.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/atan2.f90
184 ! RUN: bbc -emit-fir %t/atan2.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/atan2.f90
185 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/atan2.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/atan2.f90
186 ! RUN: bbc -emit-fir %t/atan2.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/atan2.f90
187 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/atan2.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/atan2.f90
189 function test_real4(x, y)
190 real :: x, y, test_real4
191 test_real4 = atan2(x, y)
192 end function
194 ! ALL-LABEL: @_QPtest_real4
195 ! FAST: {{%[A-Za-z0-9._]+}} = math.atan2 {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f32
196 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.atan2 {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f32
197 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @atan2f({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) {{.*}}: (f32, f32) -> f32
199 function test_real8(x, y)
200 real(8) :: x, y, test_real8
201 test_real8 = atan2(x, y)
202 end function
204 ! ALL-LABEL: @_QPtest_real8
205 ! FAST: {{%[A-Za-z0-9._]+}} = math.atan2 {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f64
206 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.atan2 {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f64
207 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @atan2({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) {{.*}}: (f64, f64) -> f64
209 ! PRECISE-DAG: func.func private @atan2f(f32, f32) -> f32 attributes {fir.bindc_name = "atan2f", fir.runtime}
210 ! PRECISE-DAG: func.func private @atan2(f64, f64) -> f64 attributes {fir.bindc_name = "atan2", fir.runtime}
212 //--- ceiling.f90
213 ! RUN: bbc -emit-fir %t/ceiling.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/ceiling.f90
214 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/ceiling.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/ceiling.f90
215 ! RUN: bbc -emit-fir %t/ceiling.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/ceiling.f90
216 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/ceiling.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/ceiling.f90
217 ! RUN: bbc -emit-fir %t/ceiling.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/ceiling.f90
218 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/ceiling.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/ceiling.f90
220 function test_real4(x)
221 real :: x, test_real4
222 test_real4 = ceiling(x)
223 end function
225 ! ALL-LABEL: @_QPtest_real4
226 ! FAST: {{%[A-Za-z0-9._]+}} = math.ceil {{%[A-Za-z0-9._]+}} {{.*}}: f32
227 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.ceil {{%[A-Za-z0-9._]+}} {{.*}}: f32
228 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @ceilf({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> f32
230 function test_real8(x)
231 real(8) :: x, test_real8
232 test_real8 = ceiling(x)
233 end function
235 ! ALL-LABEL: @_QPtest_real8
236 ! FAST: {{%[A-Za-z0-9._]+}} = math.ceil {{%[A-Za-z0-9._]+}} {{.*}}: f64
237 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.ceil {{%[A-Za-z0-9._]+}} {{.*}}: f64
238 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @ceil({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> f64
240 ! PRECISE-DAG: func.func private @ceilf(f32) -> f32 attributes {fir.bindc_name = "ceilf", fir.runtime}
241 ! PRECISE-DAG: func.func private @ceil(f64) -> f64 attributes {fir.bindc_name = "ceil", fir.runtime}
243 //--- cos.f90
244 ! RUN: bbc -emit-fir %t/cos.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/cos.f90
245 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/cos.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/cos.f90
246 ! RUN: bbc -emit-fir %t/cos.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/cos.f90
247 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/cos.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/cos.f90
248 ! RUN: bbc -emit-fir %t/cos.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/cos.f90
249 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/cos.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/cos.f90
251 function test_real4(x)
252 real :: x, test_real4
253 test_real4 = cos(x)
254 end function
256 ! ALL-LABEL: @_QPtest_real4
257 ! FAST: {{%[A-Za-z0-9._]+}} = math.cos {{%[A-Za-z0-9._]+}} {{.*}}: f32
258 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.cos {{%[A-Za-z0-9._]+}} {{.*}}: f32
259 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @cosf({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> f32
261 function test_real8(x)
262 real(8) :: x, test_real8
263 test_real8 = cos(x)
264 end function
266 ! ALL-LABEL: @_QPtest_real8
267 ! FAST: {{%[A-Za-z0-9._]+}} = math.cos {{%[A-Za-z0-9._]+}} {{.*}}: f64
268 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.cos {{%[A-Za-z0-9._]+}} {{.*}}: f64
269 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @cos({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> f64
271 ! PRECISE-DAG: func.func private @cosf(f32) -> f32 attributes {fir.bindc_name = "cosf", fir.runtime}
272 ! PRECISE-DAG: func.func private @cos(f64) -> f64 attributes {fir.bindc_name = "cos", fir.runtime}
274 //--- cosh.f90
275 ! RUN: bbc -emit-fir %t/cosh.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL %t/cosh.f90
276 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/cosh.f90 -o - | FileCheck --check-prefixes=ALL %t/cosh.f90
277 ! RUN: bbc -emit-fir %t/cosh.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL %t/cosh.f90
278 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/cosh.f90 -o - | FileCheck --check-prefixes=ALL %t/cosh.f90
279 ! RUN: bbc -emit-fir %t/cosh.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL %t/cosh.f90
280 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/cosh.f90 -o - | FileCheck --check-prefixes=ALL %t/cosh.f90
282 function test_real4(x)
283 real :: x, test_real4
284 test_real4 = cosh(x)
285 end function
287 ! ALL-LABEL: @_QPtest_real4
288 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @coshf({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> f32
290 function test_real8(x)
291 real(8) :: x, test_real8
292 test_real8 = cosh(x)
293 end function
295 ! ALL-LABEL: @_QPtest_real8
296 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @cosh({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> f64
298 ! ALL-DAG: func.func private @coshf(f32) -> f32 attributes {fir.bindc_name = "coshf", fir.runtime}
299 ! ALL-DAG: func.func private @cosh(f64) -> f64 attributes {fir.bindc_name = "cosh", fir.runtime}
301 //--- erf.f90
302 ! RUN: bbc -emit-fir %t/erf.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/erf.f90
303 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/erf.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/erf.f90
304 ! RUN: bbc -emit-fir %t/erf.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/erf.f90
305 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/erf.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/erf.f90
306 ! RUN: bbc -emit-fir %t/erf.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/erf.f90
307 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/erf.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/erf.f90
309 function test_real4(x)
310 real :: x, test_real4
311 test_real4 = erf(x)
312 end function
314 ! ALL-LABEL: @_QPtest_real4
315 ! FAST: {{%[A-Za-z0-9._]+}} = math.erf {{%[A-Za-z0-9._]+}} {{.*}}: f32
316 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.erf {{%[A-Za-z0-9._]+}} {{.*}}: f32
317 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @erff({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> f32
319 function test_real8(x)
320 real(8) :: x, test_real8
321 test_real8 = erf(x)
322 end function
324 ! ALL-LABEL: @_QPtest_real8
325 ! FAST: {{%[A-Za-z0-9._]+}} = math.erf {{%[A-Za-z0-9._]+}} {{.*}}: f64
326 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.erf {{%[A-Za-z0-9._]+}} {{.*}}: f64
327 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @erf({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> f64
329 ! PRECISE-DAG: func.func private @erff(f32) -> f32 attributes {fir.bindc_name = "erff", fir.runtime}
330 ! PRECISE-DAG: func.func private @erf(f64) -> f64 attributes {fir.bindc_name = "erf", fir.runtime}
332 //--- exp.f90
333 ! RUN: bbc -emit-fir %t/exp.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/exp.f90
334 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/exp.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/exp.f90
335 ! RUN: bbc -emit-fir %t/exp.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/exp.f90
336 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/exp.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/exp.f90
337 ! RUN: bbc -emit-fir %t/exp.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/exp.f90
338 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/exp.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/exp.f90
340 function test_real4(x)
341 real :: x, test_real4
342 test_real4 = exp(x)
343 end function
345 ! ALL-LABEL: @_QPtest_real4
346 ! FAST: {{%[A-Za-z0-9._]+}} = math.exp {{%[A-Za-z0-9._]+}} {{.*}}: f32
347 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.exp {{%[A-Za-z0-9._]+}} {{.*}}: f32
348 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @expf({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> f32
350 function test_real8(x)
351 real(8) :: x, test_real8
352 test_real8 = exp(x)
353 end function
355 ! ALL-LABEL: @_QPtest_real8
356 ! FAST: {{%[A-Za-z0-9._]+}} = math.exp {{%[A-Za-z0-9._]+}} {{.*}}: f64
357 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.exp {{%[A-Za-z0-9._]+}} {{.*}}: f64
358 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @exp({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> f64
360 ! PRECISE-DAG: func.func private @expf(f32) -> f32 attributes {fir.bindc_name = "expf", fir.runtime}
361 ! PRECISE-DAG: func.func private @exp(f64) -> f64 attributes {fir.bindc_name = "exp", fir.runtime}
363 //--- floor.f90
364 ! RUN: bbc -emit-fir %t/floor.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/floor.f90
365 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/floor.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/floor.f90
366 ! RUN: bbc -emit-fir %t/floor.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/floor.f90
367 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/floor.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/floor.f90
368 ! RUN: bbc -emit-fir %t/floor.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/floor.f90
369 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/floor.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/floor.f90
371 function test_real4(x)
372 real :: x, test_real4
373 test_real4 = floor(x)
374 end function
376 ! ALL-LABEL: @_QPtest_real4
377 ! FAST: {{%[A-Za-z0-9._]+}} = math.floor {{%[A-Za-z0-9._]+}} {{.*}}: f32
378 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.floor {{%[A-Za-z0-9._]+}} {{.*}}: f32
379 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @floorf({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> f32
381 function test_real8(x)
382 real(8) :: x, test_real8
383 test_real8 = floor(x)
384 end function
386 ! ALL-LABEL: @_QPtest_real8
387 ! FAST: {{%[A-Za-z0-9._]+}} = math.floor {{%[A-Za-z0-9._]+}} {{.*}}: f64
388 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.floor {{%[A-Za-z0-9._]+}} {{.*}}: f64
389 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @floor({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> f64
391 ! PRECISE-DAG: func.func private @floorf(f32) -> f32 attributes {fir.bindc_name = "floorf", fir.runtime}
392 ! PRECISE-DAG: func.func private @floor(f64) -> f64 attributes {fir.bindc_name = "floor", fir.runtime}
394 //--- log.f90
395 ! RUN: bbc -emit-fir %t/log.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/log.f90
396 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/log.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/log.f90
397 ! RUN: bbc -emit-fir %t/log.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/log.f90
398 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/log.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/log.f90
399 ! RUN: bbc -emit-fir %t/log.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/log.f90
400 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/log.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/log.f90
402 function test_real4(x)
403 real :: x, test_real4
404 test_real4 = log(x)
405 end function
407 ! ALL-LABEL: @_QPtest_real4
408 ! FAST: {{%[A-Za-z0-9._]+}} = math.log {{%[A-Za-z0-9._]+}} {{.*}}: f32
409 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.log {{%[A-Za-z0-9._]+}} {{.*}}: f32
410 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @logf({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> f32
412 function test_real8(x)
413 real(8) :: x, test_real8
414 test_real8 = log(x)
415 end function
417 ! ALL-LABEL: @_QPtest_real8
418 ! FAST: {{%[A-Za-z0-9._]+}} = math.log {{%[A-Za-z0-9._]+}} {{.*}}: f64
419 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.log {{%[A-Za-z0-9._]+}} {{.*}}: f64
420 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @log({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> f64
422 ! PRECISE-DAG: func.func private @logf(f32) -> f32 attributes {fir.bindc_name = "logf", fir.runtime}
423 ! PRECISE-DAG: func.func private @log(f64) -> f64 attributes {fir.bindc_name = "log", fir.runtime}
425 //--- log10.f90
426 ! RUN: bbc -emit-fir %t/log10.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/log10.f90
427 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/log10.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/log10.f90
428 ! RUN: bbc -emit-fir %t/log10.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/log10.f90
429 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/log10.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/log10.f90
430 ! RUN: bbc -emit-fir %t/log10.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/log10.f90
431 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/log10.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/log10.f90
433 function test_real4(x)
434 real :: x, test_real4
435 test_real4 = log10(x)
436 end function
438 ! ALL-LABEL: @_QPtest_real4
439 ! FAST: {{%[A-Za-z0-9._]+}} = math.log10 {{%[A-Za-z0-9._]+}} {{.*}}: f32
440 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.log10 {{%[A-Za-z0-9._]+}} {{.*}}: f32
441 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @log10f({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> f32
443 function test_real8(x)
444 real(8) :: x, test_real8
445 test_real8 = log10(x)
446 end function
448 ! ALL-LABEL: @_QPtest_real8
449 ! FAST: {{%[A-Za-z0-9._]+}} = math.log10 {{%[A-Za-z0-9._]+}} {{.*}}: f64
450 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.log10 {{%[A-Za-z0-9._]+}} {{.*}}: f64
451 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @log10({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> f64
453 ! PRECISE-DAG: func.func private @log10f(f32) -> f32 attributes {fir.bindc_name = "log10f", fir.runtime}
454 ! PRECISE-DAG: func.func private @log10(f64) -> f64 attributes {fir.bindc_name = "log10", fir.runtime}
456 //--- nint.f90
457 ! RUN: bbc -emit-fir %t/nint.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL %t/nint.f90
458 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/nint.f90 -o - | FileCheck --check-prefixes=ALL %t/nint.f90
459 ! RUN: bbc -emit-fir %t/nint.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL %t/nint.f90
460 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/nint.f90 -o - | FileCheck --check-prefixes=ALL %t/nint.f90
461 ! RUN: bbc -emit-fir %t/nint.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL %t/nint.f90
462 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/nint.f90 -o - | FileCheck --check-prefixes=ALL %t/nint.f90
464 function test_real4(x)
465 real :: x, test_real4
466 test_real4 = nint(x, 4) + nint(x, 8)
467 end function
469 ! ALL-LABEL: @_QPtest_real4
470 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.lround.i32.f32({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> i32
471 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.lround.i64.f32({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> i64
473 function test_real8(x)
474 real(8) :: x, test_real8
475 test_real8 = nint(x, 4) + nint(x, 8)
476 end function
478 ! ALL-LABEL: @_QPtest_real8
479 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.lround.i32.f64({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> i32
480 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.lround.i64.f64({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> i64
482 ! ALL-DAG: func.func private @llvm.lround.i32.f32(f32) -> i32 attributes {fir.bindc_name = "llvm.lround.i32.f32", fir.runtime}
483 ! ALL-DAG: func.func private @llvm.lround.i64.f32(f32) -> i64 attributes {fir.bindc_name = "llvm.lround.i64.f32", fir.runtime}
484 ! ALL-DAG: func.func private @llvm.lround.i32.f64(f64) -> i32 attributes {fir.bindc_name = "llvm.lround.i32.f64", fir.runtime}
485 ! ALL-DAG: func.func private @llvm.lround.i64.f64(f64) -> i64 attributes {fir.bindc_name = "llvm.lround.i64.f64", fir.runtime}
487 //--- exponentiation.f90
488 ! RUN: bbc -emit-fir %t/exponentiation.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/exponentiation.f90
489 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/exponentiation.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/exponentiation.f90
490 ! RUN: bbc -emit-fir %t/exponentiation.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/exponentiation.f90
491 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/exponentiation.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/exponentiation.f90
492 ! RUN: bbc -emit-fir %t/exponentiation.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/exponentiation.f90
493 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/exponentiation.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/exponentiation.f90
495 function test_real4(x, y, s, i, k)
496 real :: x, y, test_real4
497 integer(2) :: s
498 integer(4) :: i
499 integer(8) :: k
500 test_real4 = x ** s + x ** y + x ** i + x ** k
501 end function
503 ! ALL-LABEL: @_QPtest_real4
504 ! ALL: [[STOI:%[A-Za-z0-9._]+]] = fir.convert {{%[A-Za-z0-9._]+}} : (i16) -> i32
505 ! FAST: {{%[A-Za-z0-9._]+}} = math.fpowi {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f32, i32
506 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.fpowi {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f32, i32
507 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @_FortranAFPow4i({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) {{.*}}: (f32, i32) -> f32
508 ! FAST: {{%[A-Za-z0-9._]+}} = math.powf {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f32
509 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.powf {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f32
510 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @powf({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) {{.*}}: (f32, f32) -> f32
511 ! FAST: {{%[A-Za-z0-9._]+}} = math.fpowi {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f32, i32
512 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.fpowi {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f32, i32
513 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @_FortranAFPow4i({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) {{.*}}: (f32, i32) -> f32
514 ! FAST: {{%[A-Za-z0-9._]+}} = math.fpowi {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f32, i64
515 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.fpowi {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f32, i64
516 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @_FortranAFPow4k({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) {{.*}}: (f32, i64) -> f32
518 function test_real8(x, y, s, i, k)
519 real(8) :: x, y, test_real8
520 integer(2) :: s
521 integer(4) :: i
522 integer(8) :: k
523 test_real8 = x ** s + x ** y + x ** i + x ** k
524 end function
526 ! ALL-LABEL: @_QPtest_real8
527 ! ALL: [[STOI:%[A-Za-z0-9._]+]] = fir.convert {{%[A-Za-z0-9._]+}} : (i16) -> i32
528 ! FAST: {{%[A-Za-z0-9._]+}} = math.fpowi {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f64, i32
529 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.fpowi {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f64, i32
530 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @_FortranAFPow8i({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) {{.*}}: (f64, i32) -> f64
531 ! FAST: {{%[A-Za-z0-9._]+}} = math.powf {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f64
532 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.powf {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f64
533 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @pow({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) {{.*}}: (f64, f64) -> f64
534 ! FAST: {{%[A-Za-z0-9._]+}} = math.fpowi {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f64, i32
535 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.fpowi {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f64, i32
536 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @_FortranAFPow8i({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) {{.*}}: (f64, i32) -> f64
537 ! FAST: {{%[A-Za-z0-9._]+}} = math.fpowi {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f64, i64
538 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.fpowi {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f64, i64
539 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @_FortranAFPow8k({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) {{.*}}: (f64, i64) -> f64
541 ! PRECISE-DAG: func.func private @_FortranAFPow4i(f32, i32) -> f32 attributes {fir.bindc_name = "_FortranAFPow4i", fir.runtime}
542 ! PRECISE-DAG: func.func private @powf(f32, f32) -> f32 attributes {fir.bindc_name = "powf", fir.runtime}
543 ! PRECISE-DAG: func.func private @_FortranAFPow4k(f32, i64) -> f32 attributes {fir.bindc_name = "_FortranAFPow4k", fir.runtime}
544 ! PRECISE-DAG: func.func private @_FortranAFPow8i(f64, i32) -> f64 attributes {fir.bindc_name = "_FortranAFPow8i", fir.runtime}
545 ! PRECISE-DAG: func.func private @pow(f64, f64) -> f64 attributes {fir.bindc_name = "pow", fir.runtime}
546 ! PRECISE-DAG: func.func private @_FortranAFPow8k(f64, i64) -> f64 attributes {fir.bindc_name = "_FortranAFPow8k", fir.runtime}
548 //--- sign.f90
549 ! RUN: bbc -emit-fir %t/sign.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/sign.f90
550 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/sign.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/sign.f90
551 ! RUN: bbc -emit-fir %t/sign.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/sign.f90
552 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/sign.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/sign.f90
553 ! RUN: bbc -emit-fir %t/sign.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/sign.f90
554 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/sign.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/sign.f90
556 function test_real4(x, y)
557 real :: x, y, test_real4
558 test_real4 = sign(x, y)
559 end function
561 ! ALL-LABEL: @_QPtest_real4
562 ! FAST: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f32
563 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f32
564 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @copysignf({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) {{.*}}: (f32, f32) -> f32
566 function test_real8(x, y)
567 real(8) :: x, y, test_real8
568 test_real8 = sign(x, y)
569 end function
571 ! ALL-LABEL: @_QPtest_real8
572 ! FAST: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f64
573 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f64
574 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @copysign({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) {{.*}}: (f64, f64) -> f64
576 function test_real10(x, y)
577 real(10) :: x, y, test_real10
578 test_real10 = sign(x, y)
579 end function
581 ! ALL-LABEL: @_QPtest_real10
582 ! FAST: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f80
583 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f80
584 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @copysignl({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) {{.*}}: (f80, f80) -> f80
586 function test_real16(x, y)
587 real(16) :: x, y, test_real16
588 test_real16 = sign(x, y)
589 end function
591 ! ALL-LABEL: @_QPtest_real16
592 ! FAST: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f128
593 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.copysign {{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}} {{.*}}: f128
594 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.copysign.f128({{%[A-Za-z0-9._]+}}, {{%[A-Za-z0-9._]+}}) {{.*}}: (f128, f128) -> f128
596 ! PRECISE-DAG: func.func private @copysignf(f32, f32) -> f32 attributes {fir.bindc_name = "copysignf", fir.runtime}
597 ! PRECISE-DAG: func.func private @copysign(f64, f64) -> f64 attributes {fir.bindc_name = "copysign", fir.runtime}
598 ! PRECISE-DAG: func.func private @copysignl(f80, f80) -> f80 attributes {fir.bindc_name = "copysignl", fir.runtime}
599 ! PRECISE-DAG: func.func private @llvm.copysign.f128(f128, f128) -> f128 attributes {fir.bindc_name = "llvm.copysign.f128", fir.runtime}
601 //--- sin.f90
602 ! RUN: bbc -emit-fir %t/sin.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/sin.f90
603 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/sin.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/sin.f90
604 ! RUN: bbc -emit-fir %t/sin.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/sin.f90
605 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/sin.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/sin.f90
606 ! RUN: bbc -emit-fir %t/sin.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/sin.f90
607 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/sin.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/sin.f90
609 function test_real4(x)
610 real :: x, test_real4
611 test_real4 = sin(x)
612 end function
614 ! ALL-LABEL: @_QPtest_real4
615 ! FAST: {{%[A-Za-z0-9._]+}} = math.sin {{%[A-Za-z0-9._]+}} {{.*}}: f32
616 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.sin {{%[A-Za-z0-9._]+}} {{.*}}: f32
617 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @sinf({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> f32
619 function test_real8(x)
620 real(8) :: x, test_real8
621 test_real8 = sin(x)
622 end function
624 ! ALL-LABEL: @_QPtest_real8
625 ! FAST: {{%[A-Za-z0-9._]+}} = math.sin {{%[A-Za-z0-9._]+}} {{.*}}: f64
626 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.sin {{%[A-Za-z0-9._]+}} {{.*}}: f64
627 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @sin({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> f64
629 ! PRECISE-DAG: func.func private @sinf(f32) -> f32 attributes {fir.bindc_name = "sinf", fir.runtime}
630 ! PRECISE-DAG: func.func private @sin(f64) -> f64 attributes {fir.bindc_name = "sin", fir.runtime}
632 //--- sinh.f90
633 ! RUN: bbc -emit-fir %t/sinh.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL %t/sinh.f90
634 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/sinh.f90 -o - | FileCheck --check-prefixes=ALL %t/sinh.f90
635 ! RUN: bbc -emit-fir %t/sinh.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL %t/sinh.f90
636 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/sinh.f90 -o - | FileCheck --check-prefixes=ALL %t/sinh.f90
637 ! RUN: bbc -emit-fir %t/sinh.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL %t/sinh.f90
638 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/sinh.f90 -o - | FileCheck --check-prefixes=ALL %t/sinh.f90
640 function test_real4(x)
641 real :: x, test_real4
642 test_real4 = sinh(x)
643 end function
645 ! ALL-LABEL: @_QPtest_real4
646 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @sinhf({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> f32
648 function test_real8(x)
649 real(8) :: x, test_real8
650 test_real8 = sinh(x)
651 end function
653 ! ALL-LABEL: @_QPtest_real8
654 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @sinh({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> f64
656 ! ALL-DAG: func.func private @sinhf(f32) -> f32 attributes {fir.bindc_name = "sinhf", fir.runtime}
657 ! ALL-DAG: func.func private @sinh(f64) -> f64 attributes {fir.bindc_name = "sinh", fir.runtime}
659 //--- tanh.f90
660 ! RUN: bbc -emit-fir %t/tanh.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/tanh.f90
661 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/tanh.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/tanh.f90
662 ! RUN: bbc -emit-fir %t/tanh.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/tanh.f90
663 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/tanh.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/tanh.f90
664 ! RUN: bbc -emit-fir %t/tanh.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/tanh.f90
665 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/tanh.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/tanh.f90
667 function test_real4(x)
668 real :: x, test_real4
669 test_real4 = tanh(x)
670 end function
672 ! ALL-LABEL: @_QPtest_real4
673 ! FAST: {{%[A-Za-z0-9._]+}} = math.tanh {{%[A-Za-z0-9._]+}} {{.*}}: f32
674 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.tanh {{%[A-Za-z0-9._]+}} {{.*}}: f32
675 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @tanhf({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> f32
677 function test_real8(x)
678 real(8) :: x, test_real8
679 test_real8 = tanh(x)
680 end function
682 ! ALL-LABEL: @_QPtest_real8
683 ! FAST: {{%[A-Za-z0-9._]+}} = math.tanh {{%[A-Za-z0-9._]+}} {{.*}}: f64
684 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.tanh {{%[A-Za-z0-9._]+}} {{.*}}: f64
685 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @tanh({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> f64
687 ! PRECISE-DAG: func.func private @tanhf(f32) -> f32 attributes {fir.bindc_name = "tanhf", fir.runtime}
688 ! PRECISE-DAG: func.func private @tanh(f64) -> f64 attributes {fir.bindc_name = "tanh", fir.runtime}
690 //--- tan.f90
691 ! RUN: bbc -emit-fir %t/tan.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/tan.f90
692 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=fast %t/tan.f90 -o - | FileCheck --check-prefixes=ALL,FAST %t/tan.f90
693 ! RUN: bbc -emit-fir %t/tan.f90 -o - --math-runtime=relaxed | FileCheck --check-prefixes=ALL,RELAXED %t/tan.f90
694 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=relaxed %t/tan.f90 -o - | FileCheck --check-prefixes=ALL,RELAXED %t/tan.f90
695 ! RUN: bbc -emit-fir %t/tan.f90 -o - --math-runtime=precise | FileCheck --check-prefixes=ALL,PRECISE %t/tan.f90
696 ! RUN: %flang_fc1 -emit-fir -mllvm -math-runtime=precise %t/tan.f90 -o - | FileCheck --check-prefixes=ALL,PRECISE %t/tan.f90
698 function test_real4(x)
699 real :: x, test_real4
700 test_real4 = tan(x)
701 end function
703 ! ALL-LABEL: @_QPtest_real4
704 ! FAST: {{%[A-Za-z0-9._]+}} = math.tan {{%[A-Za-z0-9._]+}} {{.*}}: f32
705 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.tan {{%[A-Za-z0-9._]+}} {{.*}}: f32
706 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @tanf({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> f32
708 function test_real8(x)
709 real(8) :: x, test_real8
710 test_real8 = tan(x)
711 end function
713 ! ALL-LABEL: @_QPtest_real8
714 ! FAST: {{%[A-Za-z0-9._]+}} = math.tan {{%[A-Za-z0-9._]+}} {{.*}}: f64
715 ! RELAXED: {{%[A-Za-z0-9._]+}} = math.tan {{%[A-Za-z0-9._]+}} {{.*}}: f64
716 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @tan({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> f64
718 ! PRECISE-DAG: func.func private @tanf(f32) -> f32 attributes {fir.bindc_name = "tanf", fir.runtime}
719 ! PRECISE-DAG: func.func private @tan(f64) -> f64 attributes {fir.bindc_name = "tan", fir.runtime}