1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zbb,+zfh -verify-machineinstrs -mcpu=sifive-u74 \
3 ; RUN: -O1 -riscv-enable-machine-combiner=true -riscv-force-machine-combiner-strategy=local < %s | \
4 ; RUN: FileCheck %s --check-prefixes=CHECK,CHECK_LOCAL
6 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zbb,+zfh -verify-machineinstrs -mcpu=sifive-u74 \
7 ; RUN: -O1 -riscv-enable-machine-combiner=true -riscv-force-machine-combiner-strategy=min-instr < %s | \
8 ; RUN: FileCheck %s --check-prefixes=CHECK,CHECK_GLOBAL
10 define double @test_reassoc_fadd1(double %a0, double %a1, double %a2, double %a3) {
11 ; CHECK-LABEL: test_reassoc_fadd1:
13 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
14 ; CHECK-NEXT: fadd.d fa4, fa2, fa3
15 ; CHECK-NEXT: fadd.d fa0, fa5, fa4
17 %t0 = fadd nsz reassoc double %a0, %a1
18 %t1 = fadd nsz reassoc double %t0, %a2
19 %t2 = fadd nsz reassoc double %t1, %a3
23 define double @test_reassoc_fadd2(double %a0, double %a1, double %a2, double %a3) {
24 ; CHECK-LABEL: test_reassoc_fadd2:
26 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
27 ; CHECK-NEXT: fadd.d fa4, fa2, fa3
28 ; CHECK-NEXT: fadd.d fa0, fa4, fa5
30 %t0 = fadd nsz reassoc double %a0, %a1
31 %t1 = fadd nsz reassoc double %a2, %t0
32 %t2 = fadd nsz reassoc double %t1, %a3
36 define double @test_reassoc_fadd3(double %a0, double %a1, double %a2, double %a3) {
37 ; CHECK-LABEL: test_reassoc_fadd3:
39 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
40 ; CHECK-NEXT: fadd.d fa4, fa3, fa2
41 ; CHECK-NEXT: fadd.d fa0, fa4, fa5
43 %t0 = fadd nsz reassoc double %a0, %a1
44 %t1 = fadd nsz reassoc double %t0, %a2
45 %t2 = fadd nsz reassoc double %a3, %t1
49 define double @test_reassoc_fadd4(double %a0, double %a1, double %a2, double %a3) {
50 ; CHECK-LABEL: test_reassoc_fadd4:
52 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
53 ; CHECK-NEXT: fadd.d fa4, fa3, fa2
54 ; CHECK-NEXT: fadd.d fa0, fa4, fa5
56 %t0 = fadd nsz reassoc double %a0, %a1
57 %t1 = fadd nsz reassoc double %a2, %t0
58 %t2 = fadd nsz reassoc double %a3, %t1
62 define double @test_reassoc_fmul1(double %a0, double %a1, double %a2, double %a3) {
63 ; CHECK-LABEL: test_reassoc_fmul1:
65 ; CHECK-NEXT: fmul.d fa5, fa0, fa1
66 ; CHECK-NEXT: fmul.d fa4, fa2, fa3
67 ; CHECK-NEXT: fmul.d fa0, fa5, fa4
69 %t0 = fmul nsz reassoc double %a0, %a1
70 %t1 = fmul nsz reassoc double %t0, %a2
71 %t2 = fmul nsz reassoc double %t1, %a3
75 define double @test_reassoc_fmul2(double %a0, double %a1, double %a2, double %a3) {
76 ; CHECK-LABEL: test_reassoc_fmul2:
78 ; CHECK-NEXT: fmul.d fa5, fa0, fa1
79 ; CHECK-NEXT: fmul.d fa4, fa2, fa3
80 ; CHECK-NEXT: fmul.d fa0, fa4, fa5
82 %t0 = fmul nsz reassoc double %a0, %a1
83 %t1 = fmul nsz reassoc double %a2, %t0
84 %t2 = fmul nsz reassoc double %t1, %a3
88 define double @test_reassoc_fmul3(double %a0, double %a1, double %a2, double %a3) {
89 ; CHECK-LABEL: test_reassoc_fmul3:
91 ; CHECK-NEXT: fmul.d fa5, fa0, fa1
92 ; CHECK-NEXT: fmul.d fa4, fa3, fa2
93 ; CHECK-NEXT: fmul.d fa0, fa4, fa5
95 %t0 = fmul nsz reassoc double %a0, %a1
96 %t1 = fmul nsz reassoc double %t0, %a2
97 %t2 = fmul nsz reassoc double %a3, %t1
101 define double @test_reassoc_fmul4(double %a0, double %a1, double %a2, double %a3) {
102 ; CHECK-LABEL: test_reassoc_fmul4:
104 ; CHECK-NEXT: fmul.d fa5, fa0, fa1
105 ; CHECK-NEXT: fmul.d fa4, fa3, fa2
106 ; CHECK-NEXT: fmul.d fa0, fa4, fa5
108 %t0 = fmul nsz reassoc double %a0, %a1
109 %t1 = fmul nsz reassoc double %a2, %t0
110 %t2 = fmul nsz reassoc double %a3, %t1
114 define double @test_reassoc_big1(double %a0, double %a1, double %a2, double %a3, double %a4, double %a5, double %a6) {
115 ; CHECK-LABEL: test_reassoc_big1:
117 ; CHECK-NEXT: fadd.d fa1, fa0, fa1
118 ; CHECK-NEXT: fadd.d fa3, fa2, fa3
119 ; CHECK-NEXT: fadd.d fa5, fa4, fa5
120 ; CHECK-NEXT: fadd.d fa4, fa1, fa3
121 ; CHECK-NEXT: fadd.d fa5, fa5, fa6
122 ; CHECK-NEXT: fadd.d fa0, fa4, fa5
124 %t0 = fadd nsz reassoc double %a0, %a1
125 %t1 = fadd nsz reassoc double %t0, %a2
126 %t2 = fadd nsz reassoc double %t1, %a3
127 %t3 = fadd nsz reassoc double %t2, %a4
128 %t4 = fadd nsz reassoc double %t3, %a5
129 %t5 = fadd nsz reassoc double %t4, %a6
133 define double @test_reassoc_big2(double %a0, double %a1, i32 %a2, double %a3, i32 %a4, double %a5) {
134 ; CHECK-LABEL: test_reassoc_big2:
136 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
137 ; CHECK-NEXT: fsub.d fa4, fa3, fa2
138 ; CHECK-NEXT: fadd.d fa3, fa2, fa1
139 ; CHECK-NEXT: fcvt.d.w ft0, a0
140 ; CHECK-NEXT: fcvt.d.w ft1, a1
141 ; CHECK-NEXT: fmul.d fa2, fa2, ft0
142 ; CHECK-NEXT: fmul.d fa1, ft1, fa1
143 ; CHECK-NEXT: fsub.d fa5, fa4, fa5
144 ; CHECK-NEXT: fmul.d fa4, fa0, fa3
145 ; CHECK-NEXT: fmul.d fa3, fa1, fa2
146 ; CHECK-NEXT: fmul.d fa5, fa5, fa4
147 ; CHECK-NEXT: fmul.d fa0, fa5, fa3
149 %cvt1 = sitofp i32 %a2 to double
150 %cvt2 = sitofp i32 %a4 to double
151 %t5 = fmul nsz reassoc double %a3, %cvt1
152 %t9 = fmul nsz reassoc double %cvt2, %t5
153 %t4 = fmul nsz reassoc double %t9, %a1
154 %t0 = fadd nsz reassoc double %a0, %a1
155 %t1 = fadd nsz reassoc double %a3, %t0
156 %t3 = fadd nsz reassoc double %a3, %a1
157 %t6 = fmul nsz reassoc double %t4, %a0
158 %t2 = fsub nsz reassoc double %a5, %t1
159 %t7 = fmul nsz reassoc double %t6, %t3
160 %t8 = fmul nsz reassoc double %t2, %t7
165 define double @test_reassoc_fadd_flags_1(double %a0, double %a1, double %a2, double %a3) {
166 ; CHECK-LABEL: test_reassoc_fadd_flags_1:
168 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
169 ; CHECK-NEXT: fadd.d fa5, fa5, fa2
170 ; CHECK-NEXT: fadd.d fa0, fa5, fa3
172 %t0 = fadd nsz reassoc double %a0, %a1
173 %t1 = fadd double %t0, %a2
174 %t2 = fadd nsz reassoc double %t1, %a3
179 define double @test_reassoc_fadd_flags_2(double %a0, double %a1, double %a2, double %a3) {
180 ; CHECK-LABEL: test_reassoc_fadd_flags_2:
182 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
183 ; CHECK-NEXT: fadd.d fa5, fa5, fa2
184 ; CHECK-NEXT: fadd.d fa0, fa5, fa3
186 %t0 = fadd nsz reassoc double %a0, %a1
187 %t1 = fadd nsz reassoc double %t0, %a2
188 %t2 = fadd double %t1, %a3
192 define double @test_fmadd1(double %a0, double %a1, double %a2, double %a3) {
193 ; CHECK-LABEL: test_fmadd1:
195 ; CHECK-NEXT: fmadd.d fa5, fa0, fa1, fa2
196 ; CHECK-NEXT: fmadd.d fa4, fa0, fa1, fa3
197 ; CHECK-NEXT: fadd.d fa0, fa5, fa4
199 %t0 = fmul contract double %a0, %a1
200 %t1 = fadd contract double %t0, %a2
201 %t2 = fadd contract double %a3, %t0
202 %t3 = fadd double %t1, %t2
206 define double @test_fmadd2(double %a0, double %a1, double %a2) {
207 ; CHECK-LABEL: test_fmadd2:
209 ; CHECK-NEXT: fmul.d fa5, fa0, fa1
210 ; CHECK-NEXT: fmadd.d fa4, fa0, fa1, fa2
211 ; CHECK-NEXT: fdiv.d fa0, fa4, fa5
213 %t0 = fmul contract double %a0, %a1
214 %t1 = fadd contract double %t0, %a2
215 %t2 = fdiv double %t1, %t0
219 define double @test_fmsub(double %a0, double %a1, double %a2) {
220 ; CHECK-LABEL: test_fmsub:
222 ; CHECK-NEXT: fmul.d fa5, fa0, fa1
223 ; CHECK-NEXT: fmsub.d fa4, fa0, fa1, fa2
224 ; CHECK-NEXT: fdiv.d fa0, fa4, fa5
226 %t0 = fmul contract double %a0, %a1
227 %t1 = fsub contract double %t0, %a2
228 %t2 = fdiv double %t1, %t0
232 define double @test_fnmsub(double %a0, double %a1, double %a2) {
233 ; CHECK-LABEL: test_fnmsub:
235 ; CHECK-NEXT: fmul.d fa5, fa0, fa1
236 ; CHECK-NEXT: fnmsub.d fa4, fa0, fa1, fa2
237 ; CHECK-NEXT: fdiv.d fa0, fa4, fa5
239 %t0 = fmul contract double %a0, %a1
240 %t1 = fsub contract double %a2, %t0
241 %t2 = fdiv double %t1, %t0
245 define double @test_reassoc_fsub1(double %a0, double %a1, double %a2, double %a3) {
246 ; CHECK-LABEL: test_reassoc_fsub1:
248 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
249 ; CHECK-NEXT: fsub.d fa4, fa2, fa3
250 ; CHECK-NEXT: fadd.d fa0, fa5, fa4
252 %t0 = fadd nsz reassoc double %a0, %a1
253 %t1 = fadd nsz reassoc double %t0, %a2
254 %t2 = fsub nsz reassoc double %t1, %a3
258 define double @test_reassoc_fsub2(double %a0, double %a1, double %a2, double %a3) {
259 ; CHECK-LABEL: test_reassoc_fsub2:
261 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
262 ; CHECK-NEXT: fsub.d fa4, fa2, fa3
263 ; CHECK-NEXT: fsub.d fa0, fa5, fa4
265 %t0 = fadd nsz reassoc double %a0, %a1
266 %t1 = fsub nsz reassoc double %t0, %a2
267 %t2 = fadd nsz reassoc double %t1, %a3
271 define double @test_reassoc_fsub3(double %a0, double %a1, double %a2, double %a3) {
272 ; CHECK-LABEL: test_reassoc_fsub3:
274 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
275 ; CHECK-NEXT: fadd.d fa4, fa2, fa3
276 ; CHECK-NEXT: fsub.d fa0, fa5, fa4
278 %t0 = fadd nsz reassoc double %a0, %a1
279 %t1 = fsub nsz reassoc double %t0, %a2
280 %t2 = fsub nsz reassoc double %t1, %a3
284 define double @test_reassoc_fsub4(double %a0, double %a1, double %a2, double %a3) {
285 ; CHECK-LABEL: test_reassoc_fsub4:
287 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
288 ; CHECK-NEXT: fsub.d fa4, fa2, fa3
289 ; CHECK-NEXT: fadd.d fa0, fa4, fa5
291 %t0 = fadd nsz reassoc double %a0, %a1
292 %t1 = fadd nsz reassoc double %a2, %t0
293 %t2 = fsub nsz reassoc double %t1, %a3
297 define double @test_reassoc_fsub5(double %a0, double %a1, double %a2, double %a3) {
298 ; CHECK-LABEL: test_reassoc_fsub5:
300 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
301 ; CHECK-NEXT: fadd.d fa4, fa2, fa3
302 ; CHECK-NEXT: fsub.d fa0, fa4, fa5
304 %t0 = fadd nsz reassoc double %a0, %a1
305 %t1 = fsub nsz reassoc double %a2, %t0
306 %t2 = fadd nsz reassoc double %t1, %a3
310 define double @test_reassoc_fsub6(double %a0, double %a1, double %a2, double %a3) {
311 ; CHECK-LABEL: test_reassoc_fsub6:
313 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
314 ; CHECK-NEXT: fsub.d fa4, fa2, fa3
315 ; CHECK-NEXT: fsub.d fa0, fa4, fa5
317 %t0 = fadd nsz reassoc double %a0, %a1
318 %t1 = fsub nsz reassoc double %a2, %t0
319 %t2 = fsub nsz reassoc double %t1, %a3
323 define double @test_reassoc_fsub7(double %a0, double %a1, double %a2, double %a3) {
324 ; CHECK-LABEL: test_reassoc_fsub7:
326 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
327 ; CHECK-NEXT: fsub.d fa4, fa3, fa2
328 ; CHECK-NEXT: fsub.d fa0, fa4, fa5
330 %t0 = fadd nsz reassoc double %a0, %a1
331 %t1 = fadd nsz reassoc double %t0, %a2
332 %t2 = fsub nsz reassoc double %a3, %t1
336 define double @test_reassoc_fsub8(double %a0, double %a1, double %a2, double %a3) {
337 ; CHECK-LABEL: test_reassoc_fsub8:
339 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
340 ; CHECK-NEXT: fsub.d fa4, fa3, fa2
341 ; CHECK-NEXT: fadd.d fa0, fa4, fa5
343 %t0 = fadd nsz reassoc double %a0, %a1
344 %t1 = fsub nsz reassoc double %t0, %a2
345 %t2 = fadd nsz reassoc double %a3, %t1
349 define double @test_reassoc_fsub9(double %a0, double %a1, double %a2, double %a3) {
350 ; CHECK-LABEL: test_reassoc_fsub9:
352 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
353 ; CHECK-NEXT: fadd.d fa4, fa3, fa2
354 ; CHECK-NEXT: fsub.d fa0, fa4, fa5
356 %t0 = fadd nsz reassoc double %a0, %a1
357 %t1 = fsub nsz reassoc double %t0, %a2
358 %t2 = fsub nsz reassoc double %a3, %t1
362 define double @test_reassoc_fsub10(double %a0, double %a1, double %a2, double %a3) {
363 ; CHECK-LABEL: test_reassoc_fsub10:
365 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
366 ; CHECK-NEXT: fsub.d fa4, fa3, fa2
367 ; CHECK-NEXT: fsub.d fa0, fa4, fa5
369 %t0 = fadd nsz reassoc double %a0, %a1
370 %t1 = fadd nsz reassoc double %a2, %t0
371 %t2 = fsub nsz reassoc double %a3, %t1
375 define double @test_reassoc_fsub11(double %a0, double %a1, double %a2, double %a3) {
376 ; CHECK-LABEL: test_reassoc_fsub11:
378 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
379 ; CHECK-NEXT: fadd.d fa4, fa3, fa2
380 ; CHECK-NEXT: fsub.d fa0, fa4, fa5
382 %t0 = fadd nsz reassoc double %a0, %a1
383 %t1 = fsub nsz reassoc double %a2, %t0
384 %t2 = fadd nsz reassoc double %a3, %t1
388 define double @test_reassoc_fsub12(double %a0, double %a1, double %a2, double %a3) {
389 ; CHECK-LABEL: test_reassoc_fsub12:
391 ; CHECK-NEXT: fadd.d fa5, fa0, fa1
392 ; CHECK-NEXT: fsub.d fa4, fa3, fa2
393 ; CHECK-NEXT: fadd.d fa0, fa4, fa5
395 %t0 = fadd nsz reassoc double %a0, %a1
396 %t1 = fsub nsz reassoc double %a2, %t0
397 %t2 = fsub nsz reassoc double %a3, %t1
401 define i8 @test_reassoc_add_i8(i8 %a0, i8 %a1, i8 %a2, i8 %a3) {
402 ; CHECK-LABEL: test_reassoc_add_i8:
404 ; CHECK-NEXT: add a0, a0, a1
405 ; CHECK-NEXT: add a2, a2, a3
406 ; CHECK-NEXT: add a0, a0, a2
408 %t0 = add i8 %a0, %a1
409 %t1 = add i8 %t0, %a2
410 %t2 = add i8 %t1, %a3
414 define i16 @test_reassoc_add_i16(i16 %a0, i16 %a1, i16 %a2, i16 %a3) {
415 ; CHECK-LABEL: test_reassoc_add_i16:
417 ; CHECK-NEXT: add a0, a0, a1
418 ; CHECK-NEXT: add a2, a2, a3
419 ; CHECK-NEXT: add a0, a0, a2
421 %t0 = add i16 %a0, %a1
422 %t1 = add i16 %t0, %a2
423 %t2 = add i16 %t1, %a3
427 define i32 @test_reassoc_add_i32(i32 %a0, i32 %a1, i32 %a2, i32 %a3) {
428 ; CHECK-LABEL: test_reassoc_add_i32:
430 ; CHECK-NEXT: add a0, a0, a1
431 ; CHECK-NEXT: add a2, a2, a3
432 ; CHECK-NEXT: addw a0, a0, a2
434 %t0 = add i32 %a0, %a1
435 %t1 = add i32 %t0, %a2
436 %t2 = add i32 %t1, %a3
440 define i64 @test_reassoc_add_i64(i64 %a0, i64 %a1, i64 %a2, i64 %a3) {
441 ; CHECK-LABEL: test_reassoc_add_i64:
443 ; CHECK-NEXT: add a0, a0, a1
444 ; CHECK-NEXT: add a2, a2, a3
445 ; CHECK-NEXT: add a0, a0, a2
447 %t0 = add i64 %a0, %a1
448 %t1 = add i64 %t0, %a2
449 %t2 = add i64 %t1, %a3
453 define i32 @test_reassoc_add_sub_i32_1(i32 %a0, i32 %a1, i32 %a2, i32 %a3) {
454 ; CHECK-LABEL: test_reassoc_add_sub_i32_1:
456 ; CHECK-NEXT: add a0, a0, a1
457 ; CHECK-NEXT: subw a2, a2, a3
458 ; CHECK-NEXT: subw a0, a0, a2
460 %t0 = add i32 %a0, %a1
461 %t1 = sub i32 %t0, %a2
462 %t2 = add i32 %t1, %a3
466 define i32 @test_reassoc_add_sub_i32_2(i32 %a0, i32 %a1, i32 %a2, i32 %a3) {
467 ; CHECK-LABEL: test_reassoc_add_sub_i32_2:
469 ; CHECK-NEXT: add a0, a0, a1
470 ; CHECK-NEXT: subw a2, a2, a3
471 ; CHECK-NEXT: addw a0, a0, a2
473 %t0 = add i32 %a0, %a1
474 %t1 = add i32 %t0, %a2
475 %t2 = sub i32 %t1, %a3
479 define i32 @test_reassoc_add_sub_i32_3(i32 %a0, i32 %a1, i32 %a2, i32 %a3) {
480 ; CHECK-LABEL: test_reassoc_add_sub_i32_3:
482 ; CHECK-NEXT: add a0, a0, a1
483 ; CHECK-NEXT: add a2, a2, a3
484 ; CHECK-NEXT: subw a0, a0, a2
486 %t0 = add i32 %a0, %a1
487 %t1 = sub i32 %t0, %a2
488 %t2 = sub i32 %t1, %a3
492 define i64 @test_reassoc_add_sub_i64_1(i64 %a0, i64 %a1, i64 %a2, i64 %a3) {
493 ; CHECK-LABEL: test_reassoc_add_sub_i64_1:
495 ; CHECK-NEXT: add a0, a0, a1
496 ; CHECK-NEXT: sub a2, a2, a3
497 ; CHECK-NEXT: sub a0, a0, a2
499 %t0 = add i64 %a0, %a1
500 %t1 = sub i64 %t0, %a2
501 %t2 = add i64 %t1, %a3
505 define i64 @test_reassoc_add_sub_i64_2(i64 %a0, i64 %a1, i64 %a2, i64 %a3) {
506 ; CHECK-LABEL: test_reassoc_add_sub_i64_2:
508 ; CHECK-NEXT: add a0, a0, a1
509 ; CHECK-NEXT: sub a2, a2, a3
510 ; CHECK-NEXT: add a0, a0, a2
512 %t0 = add i64 %a0, %a1
513 %t1 = add i64 %t0, %a2
514 %t2 = sub i64 %t1, %a3
518 define i64 @test_reassoc_add_sub_i64_3(i64 %a0, i64 %a1, i64 %a2, i64 %a3) {
519 ; CHECK-LABEL: test_reassoc_add_sub_i64_3:
521 ; CHECK-NEXT: add a0, a0, a1
522 ; CHECK-NEXT: add a2, a2, a3
523 ; CHECK-NEXT: sub a0, a0, a2
525 %t0 = add i64 %a0, %a1
526 %t1 = sub i64 %t0, %a2
527 %t2 = sub i64 %t1, %a3
531 define i8 @test_reassoc_and_i8(i8 %a0, i8 %a1, i8 %a2, i8 %a3) {
532 ; CHECK-LABEL: test_reassoc_and_i8:
534 ; CHECK-NEXT: and a0, a0, a1
535 ; CHECK-NEXT: and a2, a2, a3
536 ; CHECK-NEXT: and a0, a0, a2
538 %t0 = and i8 %a0, %a1
539 %t1 = and i8 %t0, %a2
540 %t2 = and i8 %t1, %a3
544 define i16 @test_reassoc_and_i16(i16 %a0, i16 %a1, i16 %a2, i16 %a3) {
545 ; CHECK-LABEL: test_reassoc_and_i16:
547 ; CHECK-NEXT: and a0, a0, a1
548 ; CHECK-NEXT: and a2, a2, a3
549 ; CHECK-NEXT: and a0, a0, a2
551 %t0 = and i16 %a0, %a1
552 %t1 = and i16 %t0, %a2
553 %t2 = and i16 %t1, %a3
557 define i32 @test_reassoc_and_i32(i32 %a0, i32 %a1, i32 %a2, i32 %a3) {
558 ; CHECK-LABEL: test_reassoc_and_i32:
560 ; CHECK-NEXT: and a0, a0, a1
561 ; CHECK-NEXT: and a2, a2, a3
562 ; CHECK-NEXT: and a0, a0, a2
564 %t0 = and i32 %a0, %a1
565 %t1 = and i32 %t0, %a2
566 %t2 = and i32 %t1, %a3
570 define i64 @test_reassoc_and_i64(i64 %a0, i64 %a1, i64 %a2, i64 %a3) {
571 ; CHECK-LABEL: test_reassoc_and_i64:
573 ; CHECK-NEXT: and a0, a0, a1
574 ; CHECK-NEXT: and a2, a2, a3
575 ; CHECK-NEXT: and a0, a0, a2
577 %t0 = and i64 %a0, %a1
578 %t1 = and i64 %t0, %a2
579 %t2 = and i64 %t1, %a3
583 define i8 @test_reassoc_or_i8(i8 %a0, i8 %a1, i8 %a2, i8 %a3) {
584 ; CHECK-LABEL: test_reassoc_or_i8:
586 ; CHECK-NEXT: or a0, a0, a1
587 ; CHECK-NEXT: or a2, a2, a3
588 ; CHECK-NEXT: or a0, a0, a2
596 define i16 @test_reassoc_or_i16(i16 %a0, i16 %a1, i16 %a2, i16 %a3) {
597 ; CHECK-LABEL: test_reassoc_or_i16:
599 ; CHECK-NEXT: or a0, a0, a1
600 ; CHECK-NEXT: or a2, a2, a3
601 ; CHECK-NEXT: or a0, a0, a2
603 %t0 = or i16 %a0, %a1
604 %t1 = or i16 %t0, %a2
605 %t2 = or i16 %t1, %a3
609 define i32 @test_reassoc_or_i32(i32 %a0, i32 %a1, i32 %a2, i32 %a3) {
610 ; CHECK-LABEL: test_reassoc_or_i32:
612 ; CHECK-NEXT: or a0, a0, a1
613 ; CHECK-NEXT: or a2, a2, a3
614 ; CHECK-NEXT: or a0, a0, a2
616 %t0 = or i32 %a0, %a1
617 %t1 = or i32 %t0, %a2
618 %t2 = or i32 %t1, %a3
622 define i64 @test_reassoc_or_i64(i64 %a0, i64 %a1, i64 %a2, i64 %a3) {
623 ; CHECK-LABEL: test_reassoc_or_i64:
625 ; CHECK-NEXT: or a0, a0, a1
626 ; CHECK-NEXT: or a2, a2, a3
627 ; CHECK-NEXT: or a0, a0, a2
629 %t0 = or i64 %a0, %a1
630 %t1 = or i64 %t0, %a2
631 %t2 = or i64 %t1, %a3
635 define i8 @test_reassoc_xor_i8(i8 %a0, i8 %a1, i8 %a2, i8 %a3) {
636 ; CHECK-LABEL: test_reassoc_xor_i8:
638 ; CHECK-NEXT: xor a0, a0, a1
639 ; CHECK-NEXT: xor a2, a2, a3
640 ; CHECK-NEXT: xor a0, a0, a2
642 %t0 = xor i8 %a0, %a1
643 %t1 = xor i8 %t0, %a2
644 %t2 = xor i8 %t1, %a3
648 define i16 @test_reassoc_xor_i16(i16 %a0, i16 %a1, i16 %a2, i16 %a3) {
649 ; CHECK-LABEL: test_reassoc_xor_i16:
651 ; CHECK-NEXT: xor a0, a0, a1
652 ; CHECK-NEXT: xor a2, a2, a3
653 ; CHECK-NEXT: xor a0, a0, a2
655 %t0 = xor i16 %a0, %a1
656 %t1 = xor i16 %t0, %a2
657 %t2 = xor i16 %t1, %a3
661 define i32 @test_reassoc_xor_i32(i32 %a0, i32 %a1, i32 %a2, i32 %a3) {
662 ; CHECK-LABEL: test_reassoc_xor_i32:
664 ; CHECK-NEXT: xor a0, a0, a1
665 ; CHECK-NEXT: xor a2, a2, a3
666 ; CHECK-NEXT: xor a0, a0, a2
668 %t0 = xor i32 %a0, %a1
669 %t1 = xor i32 %t0, %a2
670 %t2 = xor i32 %t1, %a3
674 define i64 @test_reassoc_xor_i64(i64 %a0, i64 %a1, i64 %a2, i64 %a3) {
675 ; CHECK-LABEL: test_reassoc_xor_i64:
677 ; CHECK-NEXT: xor a0, a0, a1
678 ; CHECK-NEXT: xor a2, a2, a3
679 ; CHECK-NEXT: xor a0, a0, a2
681 %t0 = xor i64 %a0, %a1
682 %t1 = xor i64 %t0, %a2
683 %t2 = xor i64 %t1, %a3
687 define i8 @test_reassoc_mul_i8(i8 %a0, i8 %a1, i8 %a2, i8 %a3) {
688 ; CHECK-LABEL: test_reassoc_mul_i8:
690 ; CHECK-NEXT: mul a0, a0, a1
691 ; CHECK-NEXT: mul a1, a2, a3
692 ; CHECK-NEXT: mul a0, a0, a1
694 %t0 = mul i8 %a0, %a1
695 %t1 = mul i8 %t0, %a2
696 %t2 = mul i8 %t1, %a3
700 define i16 @test_reassoc_mul_i16(i16 %a0, i16 %a1, i16 %a2, i16 %a3) {
701 ; CHECK-LABEL: test_reassoc_mul_i16:
703 ; CHECK-NEXT: mul a0, a0, a1
704 ; CHECK-NEXT: mul a1, a2, a3
705 ; CHECK-NEXT: mul a0, a0, a1
707 %t0 = mul i16 %a0, %a1
708 %t1 = mul i16 %t0, %a2
709 %t2 = mul i16 %t1, %a3
713 define i32 @test_reassoc_mul_i32(i32 %a0, i32 %a1, i32 %a2, i32 %a3) {
714 ; CHECK-LABEL: test_reassoc_mul_i32:
716 ; CHECK-NEXT: mul a0, a0, a1
717 ; CHECK-NEXT: mul a1, a2, a3
718 ; CHECK-NEXT: mulw a0, a0, a1
720 %t0 = mul i32 %a0, %a1
721 %t1 = mul i32 %t0, %a2
722 %t2 = mul i32 %t1, %a3
726 define i64 @test_reassoc_mul_i64(i64 %a0, i64 %a1, i64 %a2, i64 %a3) {
727 ; CHECK-LABEL: test_reassoc_mul_i64:
729 ; CHECK-NEXT: mul a0, a0, a1
730 ; CHECK-NEXT: mul a1, a2, a3
731 ; CHECK-NEXT: mul a0, a0, a1
733 %t0 = mul i64 %a0, %a1
734 %t1 = mul i64 %t0, %a2
735 %t2 = mul i64 %t1, %a3
739 define i8 @test_reassoc_minu_i8(i8 %a0, i8 %a1, i8 %a2, i8 %a3) {
740 ; CHECK-LABEL: test_reassoc_minu_i8:
742 ; CHECK-NEXT: andi a3, a3, 255
743 ; CHECK-NEXT: andi a2, a2, 255
744 ; CHECK-NEXT: andi a1, a1, 255
745 ; CHECK-NEXT: andi a0, a0, 255
746 ; CHECK-NEXT: minu a0, a0, a1
747 ; CHECK-NEXT: minu a1, a2, a3
748 ; CHECK-NEXT: minu a0, a0, a1
750 %t0 = call i8 @llvm.umin.i8(i8 %a0, i8 %a1)
751 %t1 = call i8 @llvm.umin.i8(i8 %t0, i8 %a2)
752 %t2 = call i8 @llvm.umin.i8(i8 %t1, i8 %a3)
756 define i16 @test_reassoc_minu_i16(i16 %a0, i16 %a1, i16 %a2, i16 %a3) {
757 ; CHECK-LABEL: test_reassoc_minu_i16:
759 ; CHECK-NEXT: zext.h a3, a3
760 ; CHECK-NEXT: zext.h a2, a2
761 ; CHECK-NEXT: zext.h a1, a1
762 ; CHECK-NEXT: zext.h a0, a0
763 ; CHECK-NEXT: minu a0, a0, a1
764 ; CHECK-NEXT: minu a1, a2, a3
765 ; CHECK-NEXT: minu a0, a0, a1
767 %t0 = call i16 @llvm.umin.i16(i16 %a0, i16 %a1)
768 %t1 = call i16 @llvm.umin.i16(i16 %t0, i16 %a2)
769 %t2 = call i16 @llvm.umin.i16(i16 %t1, i16 %a3)
773 define i32 @test_reassoc_minu_i32(i32 %a0, i32 %a1, i32 %a2, i32 %a3) {
774 ; CHECK-LABEL: test_reassoc_minu_i32:
776 ; CHECK-NEXT: sext.w a3, a3
777 ; CHECK-NEXT: sext.w a2, a2
778 ; CHECK-NEXT: sext.w a1, a1
779 ; CHECK-NEXT: sext.w a0, a0
780 ; CHECK-NEXT: minu a0, a0, a1
781 ; CHECK-NEXT: minu a1, a2, a3
782 ; CHECK-NEXT: minu a0, a0, a1
784 %t0 = call i32 @llvm.umin.i32(i32 %a0, i32 %a1)
785 %t1 = call i32 @llvm.umin.i32(i32 %t0, i32 %a2)
786 %t2 = call i32 @llvm.umin.i32(i32 %t1, i32 %a3)
790 define i64 @test_reassoc_minu_i64(i64 %a0, i64 %a1, i64 %a2, i64 %a3) {
791 ; CHECK-LABEL: test_reassoc_minu_i64:
793 ; CHECK-NEXT: minu a0, a0, a1
794 ; CHECK-NEXT: minu a1, a2, a3
795 ; CHECK-NEXT: minu a0, a0, a1
797 %t0 = call i64 @llvm.umin.i64(i64 %a0, i64 %a1)
798 %t1 = call i64 @llvm.umin.i64(i64 %t0, i64 %a2)
799 %t2 = call i64 @llvm.umin.i64(i64 %t1, i64 %a3)
803 define i8 @test_reassoc_min_i8(i8 %a0, i8 %a1, i8 %a2, i8 %a3) {
804 ; CHECK-LABEL: test_reassoc_min_i8:
806 ; CHECK-NEXT: sext.b a3, a3
807 ; CHECK-NEXT: sext.b a2, a2
808 ; CHECK-NEXT: sext.b a1, a1
809 ; CHECK-NEXT: sext.b a0, a0
810 ; CHECK-NEXT: min a0, a0, a1
811 ; CHECK-NEXT: min a1, a2, a3
812 ; CHECK-NEXT: min a0, a0, a1
814 %t0 = call i8 @llvm.smin.i8(i8 %a0, i8 %a1)
815 %t1 = call i8 @llvm.smin.i8(i8 %t0, i8 %a2)
816 %t2 = call i8 @llvm.smin.i8(i8 %t1, i8 %a3)
820 define i16 @test_reassoc_min_i16(i16 %a0, i16 %a1, i16 %a2, i16 %a3) {
821 ; CHECK-LABEL: test_reassoc_min_i16:
823 ; CHECK-NEXT: sext.h a3, a3
824 ; CHECK-NEXT: sext.h a2, a2
825 ; CHECK-NEXT: sext.h a1, a1
826 ; CHECK-NEXT: sext.h a0, a0
827 ; CHECK-NEXT: min a0, a0, a1
828 ; CHECK-NEXT: min a1, a2, a3
829 ; CHECK-NEXT: min a0, a0, a1
831 %t0 = call i16 @llvm.smin.i16(i16 %a0, i16 %a1)
832 %t1 = call i16 @llvm.smin.i16(i16 %t0, i16 %a2)
833 %t2 = call i16 @llvm.smin.i16(i16 %t1, i16 %a3)
837 define i32 @test_reassoc_min_i32(i32 %a0, i32 %a1, i32 %a2, i32 %a3) {
838 ; CHECK-LABEL: test_reassoc_min_i32:
840 ; CHECK-NEXT: sext.w a3, a3
841 ; CHECK-NEXT: sext.w a2, a2
842 ; CHECK-NEXT: sext.w a1, a1
843 ; CHECK-NEXT: sext.w a0, a0
844 ; CHECK-NEXT: min a0, a0, a1
845 ; CHECK-NEXT: min a1, a2, a3
846 ; CHECK-NEXT: min a0, a0, a1
848 %t0 = call i32 @llvm.smin.i32(i32 %a0, i32 %a1)
849 %t1 = call i32 @llvm.smin.i32(i32 %t0, i32 %a2)
850 %t2 = call i32 @llvm.smin.i32(i32 %t1, i32 %a3)
854 define i64 @test_reassoc_min_i64(i64 %a0, i64 %a1, i64 %a2, i64 %a3) {
855 ; CHECK-LABEL: test_reassoc_min_i64:
857 ; CHECK-NEXT: min a0, a0, a1
858 ; CHECK-NEXT: min a1, a2, a3
859 ; CHECK-NEXT: min a0, a0, a1
861 %t0 = call i64 @llvm.smin.i64(i64 %a0, i64 %a1)
862 %t1 = call i64 @llvm.smin.i64(i64 %t0, i64 %a2)
863 %t2 = call i64 @llvm.smin.i64(i64 %t1, i64 %a3)
867 define i8 @test_reassoc_maxu_i8(i8 %a0, i8 %a1, i8 %a2, i8 %a3) {
868 ; CHECK-LABEL: test_reassoc_maxu_i8:
870 ; CHECK-NEXT: andi a3, a3, 255
871 ; CHECK-NEXT: andi a2, a2, 255
872 ; CHECK-NEXT: andi a1, a1, 255
873 ; CHECK-NEXT: andi a0, a0, 255
874 ; CHECK-NEXT: maxu a0, a0, a1
875 ; CHECK-NEXT: maxu a1, a2, a3
876 ; CHECK-NEXT: maxu a0, a0, a1
878 %t0 = call i8 @llvm.umax.i8(i8 %a0, i8 %a1)
879 %t1 = call i8 @llvm.umax.i8(i8 %t0, i8 %a2)
880 %t2 = call i8 @llvm.umax.i8(i8 %t1, i8 %a3)
884 define i16 @test_reassoc_maxu_i16(i16 %a0, i16 %a1, i16 %a2, i16 %a3) {
885 ; CHECK-LABEL: test_reassoc_maxu_i16:
887 ; CHECK-NEXT: zext.h a3, a3
888 ; CHECK-NEXT: zext.h a2, a2
889 ; CHECK-NEXT: zext.h a1, a1
890 ; CHECK-NEXT: zext.h a0, a0
891 ; CHECK-NEXT: maxu a0, a0, a1
892 ; CHECK-NEXT: maxu a1, a2, a3
893 ; CHECK-NEXT: maxu a0, a0, a1
895 %t0 = call i16 @llvm.umax.i16(i16 %a0, i16 %a1)
896 %t1 = call i16 @llvm.umax.i16(i16 %t0, i16 %a2)
897 %t2 = call i16 @llvm.umax.i16(i16 %t1, i16 %a3)
901 define i32 @test_reassoc_maxu_i32(i32 %a0, i32 %a1, i32 %a2, i32 %a3) {
902 ; CHECK-LABEL: test_reassoc_maxu_i32:
904 ; CHECK-NEXT: sext.w a3, a3
905 ; CHECK-NEXT: sext.w a2, a2
906 ; CHECK-NEXT: sext.w a1, a1
907 ; CHECK-NEXT: sext.w a0, a0
908 ; CHECK-NEXT: maxu a0, a0, a1
909 ; CHECK-NEXT: maxu a1, a2, a3
910 ; CHECK-NEXT: maxu a0, a0, a1
912 %t0 = call i32 @llvm.umax.i32(i32 %a0, i32 %a1)
913 %t1 = call i32 @llvm.umax.i32(i32 %t0, i32 %a2)
914 %t2 = call i32 @llvm.umax.i32(i32 %t1, i32 %a3)
918 define i64 @test_reassoc_maxu_i64(i64 %a0, i64 %a1, i64 %a2, i64 %a3) {
919 ; CHECK-LABEL: test_reassoc_maxu_i64:
921 ; CHECK-NEXT: maxu a0, a0, a1
922 ; CHECK-NEXT: maxu a1, a2, a3
923 ; CHECK-NEXT: maxu a0, a0, a1
925 %t0 = call i64 @llvm.umax.i64(i64 %a0, i64 %a1)
926 %t1 = call i64 @llvm.umax.i64(i64 %t0, i64 %a2)
927 %t2 = call i64 @llvm.umax.i64(i64 %t1, i64 %a3)
931 define i8 @test_reassoc_max_i8(i8 %a0, i8 %a1, i8 %a2, i8 %a3) {
932 ; CHECK-LABEL: test_reassoc_max_i8:
934 ; CHECK-NEXT: sext.b a3, a3
935 ; CHECK-NEXT: sext.b a2, a2
936 ; CHECK-NEXT: sext.b a1, a1
937 ; CHECK-NEXT: sext.b a0, a0
938 ; CHECK-NEXT: max a0, a0, a1
939 ; CHECK-NEXT: max a1, a2, a3
940 ; CHECK-NEXT: max a0, a0, a1
942 %t0 = call i8 @llvm.smax.i8(i8 %a0, i8 %a1)
943 %t1 = call i8 @llvm.smax.i8(i8 %t0, i8 %a2)
944 %t2 = call i8 @llvm.smax.i8(i8 %t1, i8 %a3)
948 define i16 @test_reassoc_max_i16(i16 %a0, i16 %a1, i16 %a2, i16 %a3) {
949 ; CHECK-LABEL: test_reassoc_max_i16:
951 ; CHECK-NEXT: sext.h a3, a3
952 ; CHECK-NEXT: sext.h a2, a2
953 ; CHECK-NEXT: sext.h a1, a1
954 ; CHECK-NEXT: sext.h a0, a0
955 ; CHECK-NEXT: max a0, a0, a1
956 ; CHECK-NEXT: max a1, a2, a3
957 ; CHECK-NEXT: max a0, a0, a1
959 %t0 = call i16 @llvm.smax.i16(i16 %a0, i16 %a1)
960 %t1 = call i16 @llvm.smax.i16(i16 %t0, i16 %a2)
961 %t2 = call i16 @llvm.smax.i16(i16 %t1, i16 %a3)
965 define i32 @test_reassoc_max_i32(i32 %a0, i32 %a1, i32 %a2, i32 %a3) {
966 ; CHECK-LABEL: test_reassoc_max_i32:
968 ; CHECK-NEXT: sext.w a3, a3
969 ; CHECK-NEXT: sext.w a2, a2
970 ; CHECK-NEXT: sext.w a1, a1
971 ; CHECK-NEXT: sext.w a0, a0
972 ; CHECK-NEXT: max a0, a0, a1
973 ; CHECK-NEXT: max a1, a2, a3
974 ; CHECK-NEXT: max a0, a0, a1
976 %t0 = call i32 @llvm.smax.i32(i32 %a0, i32 %a1)
977 %t1 = call i32 @llvm.smax.i32(i32 %t0, i32 %a2)
978 %t2 = call i32 @llvm.smax.i32(i32 %t1, i32 %a3)
982 define i64 @test_reassoc_max_i64(i64 %a0, i64 %a1, i64 %a2, i64 %a3) {
983 ; CHECK-LABEL: test_reassoc_max_i64:
985 ; CHECK-NEXT: max a0, a0, a1
986 ; CHECK-NEXT: max a1, a2, a3
987 ; CHECK-NEXT: max a0, a0, a1
989 %t0 = call i64 @llvm.smax.i64(i64 %a0, i64 %a1)
990 %t1 = call i64 @llvm.smax.i64(i64 %t0, i64 %a2)
991 %t2 = call i64 @llvm.smax.i64(i64 %t1, i64 %a3)
995 define half @test_fmin_f16(half %a0, half %a1, half %a2, half %a3) {
996 ; CHECK-LABEL: test_fmin_f16:
998 ; CHECK-NEXT: fmin.h fa5, fa0, fa1
999 ; CHECK-NEXT: fmin.h fa4, fa2, fa3
1000 ; CHECK-NEXT: fmin.h fa0, fa5, fa4
1002 %t0 = call half @llvm.minnum.f16(half %a0, half %a1)
1003 %t1 = call half @llvm.minnum.f16(half %t0, half %a2)
1004 %t2 = call half @llvm.minnum.f16(half %t1, half %a3)
1008 define float @test_fmin_f32(float %a0, float %a1, float %a2, float %a3) {
1009 ; CHECK-LABEL: test_fmin_f32:
1011 ; CHECK-NEXT: fmin.s fa5, fa0, fa1
1012 ; CHECK-NEXT: fmin.s fa4, fa2, fa3
1013 ; CHECK-NEXT: fmin.s fa0, fa5, fa4
1015 %t0 = call float @llvm.minnum.f32(float %a0, float %a1)
1016 %t1 = call float @llvm.minnum.f32(float %t0, float %a2)
1017 %t2 = call float @llvm.minnum.f32(float %t1, float %a3)
1021 define double @test_fmin_f64(double %a0, double %a1, double %a2, double %a3) {
1022 ; CHECK-LABEL: test_fmin_f64:
1024 ; CHECK-NEXT: fmin.d fa5, fa0, fa1
1025 ; CHECK-NEXT: fmin.d fa4, fa2, fa3
1026 ; CHECK-NEXT: fmin.d fa0, fa5, fa4
1028 %t0 = call double @llvm.minnum.f64(double %a0, double %a1)
1029 %t1 = call double @llvm.minnum.f64(double %t0, double %a2)
1030 %t2 = call double @llvm.minnum.f64(double %t1, double %a3)
1034 define half @test_fmax_f16(half %a0, half %a1, half %a2, half %a3) {
1035 ; CHECK-LABEL: test_fmax_f16:
1037 ; CHECK-NEXT: fmax.h fa5, fa0, fa1
1038 ; CHECK-NEXT: fmax.h fa4, fa2, fa3
1039 ; CHECK-NEXT: fmax.h fa0, fa5, fa4
1041 %t0 = call half @llvm.maxnum.f16(half %a0, half %a1)
1042 %t1 = call half @llvm.maxnum.f16(half %t0, half %a2)
1043 %t2 = call half @llvm.maxnum.f16(half %t1, half %a3)
1047 define float @test_fmax_f32(float %a0, float %a1, float %a2, float %a3) {
1048 ; CHECK-LABEL: test_fmax_f32:
1050 ; CHECK-NEXT: fmax.s fa5, fa0, fa1
1051 ; CHECK-NEXT: fmax.s fa4, fa2, fa3
1052 ; CHECK-NEXT: fmax.s fa0, fa5, fa4
1054 %t0 = call float @llvm.maxnum.f32(float %a0, float %a1)
1055 %t1 = call float @llvm.maxnum.f32(float %t0, float %a2)
1056 %t2 = call float @llvm.maxnum.f32(float %t1, float %a3)
1060 define double @test_fmax_f64(double %a0, double %a1, double %a2, double %a3) {
1061 ; CHECK-LABEL: test_fmax_f64:
1063 ; CHECK-NEXT: fmax.d fa5, fa0, fa1
1064 ; CHECK-NEXT: fmax.d fa4, fa2, fa3
1065 ; CHECK-NEXT: fmax.d fa0, fa5, fa4
1067 %t0 = call double @llvm.maxnum.f64(double %a0, double %a1)
1068 %t1 = call double @llvm.maxnum.f64(double %t0, double %a2)
1069 %t2 = call double @llvm.maxnum.f64(double %t1, double %a3)
1073 declare i8 @llvm.umin.i8(i8 %a, i8 %b)
1074 declare i16 @llvm.umin.i16(i16 %a, i16 %b)
1075 declare i32 @llvm.umin.i32(i32 %a, i32 %b)
1076 declare i64 @llvm.umin.i64(i64 %a, i64 %b)
1077 declare i8 @llvm.smin.i8(i8 %a, i8 %b)
1078 declare i16 @llvm.smin.i16(i16 %a, i16 %b)
1079 declare i32 @llvm.smin.i32(i32 %a, i32 %b)
1080 declare i64 @llvm.smin.i64(i64 %a, i64 %b)
1081 declare i8 @llvm.umax.i8(i8 %a, i8 %b)
1082 declare i16 @llvm.umax.i16(i16 %a, i16 %b)
1083 declare i32 @llvm.umax.i32(i32 %a, i32 %b)
1084 declare i64 @llvm.umax.i64(i64 %a, i64 %b)
1085 declare i8 @llvm.smax.i8(i8 %a, i8 %b)
1086 declare i16 @llvm.smax.i16(i16 %a, i16 %b)
1087 declare i32 @llvm.smax.i32(i32 %a, i32 %b)
1088 declare i64 @llvm.smax.i64(i64 %a, i64 %b)
1089 declare half @llvm.minnum.f16(half, half)
1090 declare float @llvm.minnum.f32(float, float)
1091 declare double @llvm.minnum.f64(double, double)
1092 declare half @llvm.maxnum.f16(half, half)
1093 declare float @llvm.maxnum.f32(float, float)
1094 declare double @llvm.maxnum.f64(double, double)
1096 define double @test_fmadd_strategy(double %a0, double %a1, double %a2, double %a3, i64 %flag) {
1097 ; CHECK_LOCAL-LABEL: test_fmadd_strategy:
1098 ; CHECK_LOCAL: # %bb.0: # %entry
1099 ; CHECK_LOCAL-NEXT: fmv.d fa5, fa0
1100 ; CHECK_LOCAL-NEXT: fsub.d fa4, fa0, fa1
1101 ; CHECK_LOCAL-NEXT: fmul.d fa0, fa4, fa2
1102 ; CHECK_LOCAL-NEXT: andi a0, a0, 1
1103 ; CHECK_LOCAL-NEXT: beqz a0, .LBB76_2
1104 ; CHECK_LOCAL-NEXT: # %bb.1: # %entry
1105 ; CHECK_LOCAL-NEXT: fmul.d fa4, fa5, fa1
1106 ; CHECK_LOCAL-NEXT: fmadd.d fa5, fa5, fa1, fa0
1107 ; CHECK_LOCAL-NEXT: fsub.d fa0, fa5, fa4
1108 ; CHECK_LOCAL-NEXT: .LBB76_2: # %entry
1109 ; CHECK_LOCAL-NEXT: ret
1111 ; CHECK_GLOBAL-LABEL: test_fmadd_strategy:
1112 ; CHECK_GLOBAL: # %bb.0: # %entry
1113 ; CHECK_GLOBAL-NEXT: fmv.d fa5, fa0
1114 ; CHECK_GLOBAL-NEXT: fsub.d fa4, fa0, fa1
1115 ; CHECK_GLOBAL-NEXT: fmul.d fa0, fa4, fa2
1116 ; CHECK_GLOBAL-NEXT: andi a0, a0, 1
1117 ; CHECK_GLOBAL-NEXT: beqz a0, .LBB76_2
1118 ; CHECK_GLOBAL-NEXT: # %bb.1: # %entry
1119 ; CHECK_GLOBAL-NEXT: fmul.d fa5, fa5, fa1
1120 ; CHECK_GLOBAL-NEXT: fadd.d fa4, fa5, fa0
1121 ; CHECK_GLOBAL-NEXT: fsub.d fa0, fa4, fa5
1122 ; CHECK_GLOBAL-NEXT: .LBB76_2: # %entry
1123 ; CHECK_GLOBAL-NEXT: ret
1125 %sub = fsub contract double %a0, %a1
1126 %mul = fmul contract double %sub, %a2
1127 %and = and i64 %flag, 1
1128 %tobool.not = icmp eq i64 %and, 0
1129 %mul2 = fmul contract double %a0, %a1
1130 %add = fadd contract double %mul2, %mul
1131 %sub3 = fsub contract double %add, %mul2
1132 %retval.0 = select i1 %tobool.not, double %mul, double %sub3
1133 ret double %retval.0