1 ; Check whether nmadd/nmsub instructions are properly generated
2 ; RUN: llc < %s -march=mipsel -mcpu=mips32r2 -enable-no-nans-fp-math | FileCheck %s -check-prefixes=ALL,CHECK-NM
3 ; RUN: llc < %s -march=mipsel -mcpu=mips32r2 -mattr=+fp64 -enable-no-nans-fp-math | FileCheck %s -check-prefixes=ALL,CHECK-NM
4 ; RUN: llc < %s -march=mipsel -mcpu=mips32r2 -mattr=micromips -enable-no-nans-fp-math -asm-show-inst | FileCheck %s -check-prefixes=ALL,CHECK-NM,CHECK-MM
5 ; RUN: llc < %s -march=mips64el -mcpu=mips64 -target-abi=n64 -enable-no-nans-fp-math | FileCheck %s -check-prefixes=ALL,CHECK-NM-64
6 ; RUN: llc < %s -march=mips64el -mcpu=mips64r2 -target-abi=n64 -enable-no-nans-fp-math | FileCheck %s -check-prefixes=ALL,CHECK-NM-64
7 ; RUN: llc < %s -march=mips64el -mcpu=mips4 -target-abi=n64 -enable-no-nans-fp-math | FileCheck %s -check-prefixes=ALL,CHECK-NM-64
8 ; RUN: llc < %s -march=mipsel -mcpu=mips32 -enable-no-nans-fp-math | FileCheck %s -check-prefixes=ALL,CHECK-NOT-NM
9 ; RUN: llc < %s -march=mipsel -mcpu=mips32r6 -enable-no-nans-fp-math | FileCheck %s -check-prefixes=ALL,CHECK-NOT-NM
10 ; RUN: llc < %s -march=mips64el -mcpu=mips3 -target-abi=n64 -enable-no-nans-fp-math | FileCheck %s -check-prefixes=ALL,CHECK-NOT-NM-64
11 ; RUN: llc < %s -march=mipsel -mcpu=mips32r6 -mattr=micromips -enable-no-nans-fp-math | FileCheck %s -check-prefixes=ALL,CHECK-NOT-NM
12 ; RUN: llc < %s -march=mipsel -mcpu=mips32r3 -mattr=micromips -enable-no-nans-fp-math | FileCheck %s -check-prefixes=ALL,CHECK-NM
14 define float @add1(float %f, float %g, float %h) local_unnamed_addr #0 {
18 ; CHECK-NM-64: nmadd.s $f0, $f14, $f12, $f13
19 ; CHECK-NM: nmadd.s $f0, $f0, $f12, $f14
20 ; CHECK-MM: NMADD_S_MM
21 ; CHECK-NOT-NM-64: mul.s $f0, $f12, $f13
22 ; CHECK-NOT-NM-64: neg.s $f0, $f0
23 ; CHECK-NOT-NM: mul.s $f0, $f12, $f14
24 ; CHECK-NOT-NM: neg.s $f0, $f0
26 %mul = fmul nnan float %f, %g
27 %add = fadd nnan float %mul, %h
28 %sub = fsub nnan float -0.000000e+00, %add
32 define double @add2(double %f, double %g, double %h) local_unnamed_addr #0 {
36 ; CHECK-NM-64: nmadd.d $f0, $f14, $f12, $f13
37 ; CHECK-NM: nmadd.d $f0, $f0, $f12, $f14
38 ; CHECK-MM: NMADD_D32_MM
39 ; CHECK-NOT-NM-64: mul.d $f0, $f12, $f13
40 ; CHECK-NOT-NM-64: neg.d $f0, $f0
41 ; CHECK-NOT-NM: mul.d $f0, $f12, $f14
42 ; CHECK-NOT-NM: neg.d $f0, $f0
44 %mul = fmul nnan double %f, %g
45 %add = fadd nnan double %mul, %h
46 %sub = fsub nnan double -0.000000e+00, %add
50 define float @sub1(float %f, float %g, float %h) local_unnamed_addr #0 {
54 ; CHECK-NM-64: nmsub.s $f0, $f14, $f12, $f13
55 ; CHECK-NM: nmsub.s $f0, $f0, $f12, $f14
56 ; CHECK-MM: NMSUB_S_MM
57 ; CHECK-NOT-NM-64: mul.s $f0, $f12, $f13
58 ; CHECK-NOT-NM-64: neg.s $f0, $f0
59 ; CHECK-NOT-NM: mul.s $f0, $f12, $f14
60 ; CHECK-NOT-NM: neg.s $f0, $f0
62 %mul = fmul nnan float %f, %g
63 %sub = fsub nnan float %mul, %h
64 %sub1 = fsub nnan float -0.000000e+00, %sub
68 define double @sub2(double %f, double %g, double %h) local_unnamed_addr #0 {
72 ; CHECK-NM-64: nmsub.d $f0, $f14, $f12, $f13
73 ; CHECK-NM: nmsub.d $f0, $f0, $f12, $f14
74 ; CHECK-MM: NMSUB_D32_MM
75 ; CHECK-NOT-NM-64: mul.d $f0, $f12, $f13
76 ; CHECK-NOT-NM-64: neg.d $f0, $f0
77 ; CHECK-NOT-NM: mul.d $f0, $f12, $f14
78 ; CHECK-NOT-NM: neg.d $f0, $f0
80 %mul = fmul nnan double %f, %g
81 %sub = fsub nnan double %mul, %h
82 %sub1 = fsub nnan double -0.000000e+00, %sub