Skip to content

Commit 7e5f6b1

Browse files
committed
Add snan and qnan test cases
1 parent bd34a89 commit 7e5f6b1

File tree

2 files changed

+229
-4
lines changed

2 files changed

+229
-4
lines changed

llvm/test/CodeGen/AArch64/nofpclass.ll

Lines changed: 101 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
22
; RUN: llc --mtriple=aarch64-linux-gnu < %s | FileCheck %s
33

4-
define nofpclass(nzero) float @f(float nofpclass(nan) %a, float nofpclass(nan) %b) {
4+
%struct.f2 = type { float, float }
5+
6+
define float @f(float nofpclass(nan) %a, float nofpclass(nan) %b) {
57
; CHECK-LABEL: f:
68
; CHECK: // %bb.0: // %entry
79
; CHECK-NEXT: fmaxnm s0, s0, s1
@@ -28,7 +30,6 @@ define { float, float } @struct({ float, float} nofpclass(nan) %a) {
2830
ret {float, float} %a
2931
}
3032

31-
%struct.f2 = type { float, float }
3233
define %struct.f2 @m([2 x float] nofpclass(nan) %a0, [2 x float] nofpclass(nan) %a1) {
3334
; CHECK-LABEL: m:
3435
; CHECK: // %bb.0: // %entry
@@ -46,3 +47,101 @@ entry:
4647
%ret1 = insertvalue %struct.f2 %ret0, float %max1, 1
4748
ret %struct.f2 %ret1
4849
}
50+
51+
define float @fS(float nofpclass(snan) %a, float nofpclass(snan) %b) {
52+
; CHECK-LABEL: fS:
53+
; CHECK: // %bb.0: // %entry
54+
; CHECK-NEXT: fmaxnm s0, s0, s1
55+
; CHECK-NEXT: ret
56+
entry:
57+
%cond = tail call float @llvm.maximumnum.f32(float %a, float %b)
58+
ret float %cond
59+
}
60+
61+
define <4 x float> @fSv4f32(<4 x float> nofpclass(snan) %a, <4 x float> nofpclass(snan) %b) {
62+
; CHECK-LABEL: fSv4f32:
63+
; CHECK: // %bb.0: // %entry
64+
; CHECK-NEXT: fmaxnm v0.4s, v0.4s, v1.4s
65+
; CHECK-NEXT: ret
66+
entry:
67+
%c = call <4 x float> @llvm.maximumnum.v4f32(<4 x float> %a, <4 x float> %b)
68+
ret <4 x float> %c
69+
}
70+
71+
define { float, float } @structS({ float, float} nofpclass(snan) %a) {
72+
; CHECK-LABEL: structS:
73+
; CHECK: // %bb.0:
74+
; CHECK-NEXT: ret
75+
ret {float, float} %a
76+
}
77+
78+
define %struct.f2 @mS([2 x float] nofpclass(snan) %a0, [2 x float] nofpclass(snan) %a1) {
79+
; CHECK-LABEL: mS:
80+
; CHECK: // %bb.0: // %entry
81+
; CHECK-NEXT: fmaxnm s1, s1, s3
82+
; CHECK-NEXT: fmaxnm s0, s0, s2
83+
; CHECK-NEXT: ret
84+
entry:
85+
%a0f0 = extractvalue [2 x float] %a0, 0
86+
%a0f1 = extractvalue [2 x float] %a0, 1
87+
%a1f0 = extractvalue [2 x float] %a1, 0
88+
%a1f1 = extractvalue [2 x float] %a1, 1
89+
%max0 = tail call float @llvm.maximumnum.f32(float %a0f0, float %a1f0)
90+
%max1 = tail call float @llvm.maximumnum.f32(float %a0f1, float %a1f1)
91+
%ret0 = insertvalue %struct.f2 poison, float %max0, 0
92+
%ret1 = insertvalue %struct.f2 %ret0, float %max1, 1
93+
ret %struct.f2 %ret1
94+
}
95+
96+
define float @fQ(float nofpclass(qnan) %a, float nofpclass(qnan) %b) {
97+
; CHECK-LABEL: fQ:
98+
; CHECK: // %bb.0: // %entry
99+
; CHECK-NEXT: fminnm s1, s1, s1
100+
; CHECK-NEXT: fminnm s0, s0, s0
101+
; CHECK-NEXT: fmaxnm s0, s0, s1
102+
; CHECK-NEXT: ret
103+
entry:
104+
%cond = tail call float @llvm.maximumnum.f32(float %a, float %b)
105+
ret float %cond
106+
}
107+
108+
define <4 x float> @fQv4f32(<4 x float> nofpclass(qnan) %a, <4 x float> nofpclass(qnan) %b) {
109+
; CHECK-LABEL: fQv4f32:
110+
; CHECK: // %bb.0: // %entry
111+
; CHECK-NEXT: fminnm v1.4s, v1.4s, v1.4s
112+
; CHECK-NEXT: fminnm v0.4s, v0.4s, v0.4s
113+
; CHECK-NEXT: fmaxnm v0.4s, v0.4s, v1.4s
114+
; CHECK-NEXT: ret
115+
entry:
116+
%c = call <4 x float> @llvm.maximumnum.v4f32(<4 x float> %a, <4 x float> %b)
117+
ret <4 x float> %c
118+
}
119+
120+
define { float, float } @structQ({ float, float} nofpclass(qnan) %a) {
121+
; CHECK-LABEL: structQ:
122+
; CHECK: // %bb.0:
123+
; CHECK-NEXT: ret
124+
ret {float, float} %a
125+
}
126+
127+
define %struct.f2 @mQ([2 x float] nofpclass(qnan) %a0, [2 x float] nofpclass(qnan) %a1) {
128+
; CHECK-LABEL: mQ:
129+
; CHECK: // %bb.0: // %entry
130+
; CHECK-NEXT: fminnm s2, s2, s2
131+
; CHECK-NEXT: fminnm s0, s0, s0
132+
; CHECK-NEXT: fminnm s3, s3, s3
133+
; CHECK-NEXT: fminnm s1, s1, s1
134+
; CHECK-NEXT: fmaxnm s0, s0, s2
135+
; CHECK-NEXT: fmaxnm s1, s1, s3
136+
; CHECK-NEXT: ret
137+
entry:
138+
%a0f0 = extractvalue [2 x float] %a0, 0
139+
%a0f1 = extractvalue [2 x float] %a0, 1
140+
%a1f0 = extractvalue [2 x float] %a1, 0
141+
%a1f1 = extractvalue [2 x float] %a1, 1
142+
%max0 = tail call float @llvm.maximumnum.f32(float %a0f0, float %a1f0)
143+
%max1 = tail call float @llvm.maximumnum.f32(float %a0f1, float %a1f1)
144+
%ret0 = insertvalue %struct.f2 poison, float %max0, 0
145+
%ret1 = insertvalue %struct.f2 %ret0, float %max1, 1
146+
ret %struct.f2 %ret1
147+
}

llvm/test/CodeGen/Mips/nofpclass.ll

Lines changed: 128 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
; RUN: llc --mtriple=mipsisa32r6-linux-gnu < %s | FileCheck %s --check-prefix=MIPS32R6
33
; RUN: llc --mtriple=mipsisa64r6-linux-gnu < %s | FileCheck %s --check-prefix=MIPS64R6
44

5-
define nofpclass(nzero) float @f(float nofpclass(nan) %a, float nofpclass(nan) %b) {
5+
%struct.f2 = type { float, float }
6+
7+
8+
define float @f(float nofpclass(nan) %a, float nofpclass(nan) %b) {
69
; MIPS32R6-LABEL: f:
710
; MIPS32R6: # %bb.0: # %entry
811
; MIPS32R6-NEXT: jr $ra
@@ -32,7 +35,6 @@ define { float, float } @struct({ float, float} nofpclass(nan) %a) {
3235
ret {float, float} %a
3336
}
3437

35-
%struct.f2 = type { float, float }
3638
define %struct.f2 @m([2 x float] nofpclass(nan) %a0, [2 x float] nofpclass(nan) %a1) {
3739
; MIPS32R6-LABEL: m:
3840
; MIPS32R6: # %bb.0: # %entry
@@ -58,3 +60,127 @@ entry:
5860
%ret1 = insertvalue %struct.f2 %ret0, float %max1, 1
5961
ret %struct.f2 %ret1
6062
}
63+
64+
define float @fS(float nofpclass(snan) %a, float nofpclass(snan) %b) {
65+
; MIPS32R6-LABEL: fS:
66+
; MIPS32R6: # %bb.0: # %entry
67+
; MIPS32R6-NEXT: jr $ra
68+
; MIPS32R6-NEXT: max.s $f0, $f12, $f14
69+
;
70+
; MIPS64R6-LABEL: fS:
71+
; MIPS64R6: # %bb.0: # %entry
72+
; MIPS64R6-NEXT: jr $ra
73+
; MIPS64R6-NEXT: max.s $f0, $f12, $f13
74+
entry:
75+
%cond = tail call float @llvm.maximumnum.f32(float %a, float %b)
76+
ret float %cond
77+
}
78+
79+
define { float, float } @structS({ float, float} nofpclass(snan) %a) {
80+
; MIPS32R6-LABEL: structS:
81+
; MIPS32R6: # %bb.0:
82+
; MIPS32R6-NEXT: mov.s $f2, $f14
83+
; MIPS32R6-NEXT: jr $ra
84+
; MIPS32R6-NEXT: mov.s $f0, $f12
85+
;
86+
; MIPS64R6-LABEL: structS:
87+
; MIPS64R6: # %bb.0:
88+
; MIPS64R6-NEXT: mov.s $f2, $f13
89+
; MIPS64R6-NEXT: jr $ra
90+
; MIPS64R6-NEXT: mov.s $f0, $f12
91+
ret {float, float} %a
92+
}
93+
94+
define %struct.f2 @mS([2 x float] nofpclass(snan) %a0, [2 x float] nofpclass(snan) %a1) {
95+
; MIPS32R6-LABEL: mS:
96+
; MIPS32R6: # %bb.0: # %entry
97+
; MIPS32R6-NEXT: mtc1 $6, $f0
98+
; MIPS32R6-NEXT: max.s $f0, $f12, $f0
99+
; MIPS32R6-NEXT: mtc1 $7, $f1
100+
; MIPS32R6-NEXT: jr $ra
101+
; MIPS32R6-NEXT: max.s $f2, $f14, $f1
102+
;
103+
; MIPS64R6-LABEL: mS:
104+
; MIPS64R6: # %bb.0: # %entry
105+
; MIPS64R6-NEXT: max.s $f0, $f12, $f14
106+
; MIPS64R6-NEXT: jr $ra
107+
; MIPS64R6-NEXT: max.s $f2, $f13, $f15
108+
entry:
109+
%a0f0 = extractvalue [2 x float] %a0, 0
110+
%a0f1 = extractvalue [2 x float] %a0, 1
111+
%a1f0 = extractvalue [2 x float] %a1, 0
112+
%a1f1 = extractvalue [2 x float] %a1, 1
113+
%max0 = tail call float @llvm.maximumnum.f32(float %a0f0, float %a1f0)
114+
%max1 = tail call float @llvm.maximumnum.f32(float %a0f1, float %a1f1)
115+
%ret0 = insertvalue %struct.f2 poison, float %max0, 0
116+
%ret1 = insertvalue %struct.f2 %ret0, float %max1, 1
117+
ret %struct.f2 %ret1
118+
}
119+
120+
define float @fQ(float nofpclass(qnan) %a, float nofpclass(qnan) %b) {
121+
; MIPS32R6-LABEL: fQ:
122+
; MIPS32R6: # %bb.0: # %entry
123+
; MIPS32R6-NEXT: min.s $f0, $f14, $f14
124+
; MIPS32R6-NEXT: min.s $f1, $f12, $f12
125+
; MIPS32R6-NEXT: jr $ra
126+
; MIPS32R6-NEXT: max.s $f0, $f1, $f0
127+
;
128+
; MIPS64R6-LABEL: fQ:
129+
; MIPS64R6: # %bb.0: # %entry
130+
; MIPS64R6-NEXT: min.s $f0, $f13, $f13
131+
; MIPS64R6-NEXT: min.s $f1, $f12, $f12
132+
; MIPS64R6-NEXT: jr $ra
133+
; MIPS64R6-NEXT: max.s $f0, $f1, $f0
134+
entry:
135+
%cond = tail call float @llvm.maximumnum.f32(float %a, float %b)
136+
ret float %cond
137+
}
138+
139+
define { float, float } @structQ({ float, float} nofpclass(qnan) %a) {
140+
; MIPS32R6-LABEL: structQ:
141+
; MIPS32R6: # %bb.0:
142+
; MIPS32R6-NEXT: mov.s $f2, $f14
143+
; MIPS32R6-NEXT: jr $ra
144+
; MIPS32R6-NEXT: mov.s $f0, $f12
145+
;
146+
; MIPS64R6-LABEL: structQ:
147+
; MIPS64R6: # %bb.0:
148+
; MIPS64R6-NEXT: mov.s $f2, $f13
149+
; MIPS64R6-NEXT: jr $ra
150+
; MIPS64R6-NEXT: mov.s $f0, $f12
151+
ret {float, float} %a
152+
}
153+
154+
define %struct.f2 @mQ([2 x float] nofpclass(qnan) %a0, [2 x float] nofpclass(qnan) %a1) {
155+
; MIPS32R6-LABEL: mQ:
156+
; MIPS32R6: # %bb.0: # %entry
157+
; MIPS32R6-NEXT: min.s $f0, $f12, $f12
158+
; MIPS32R6-NEXT: mtc1 $6, $f1
159+
; MIPS32R6-NEXT: min.s $f1, $f1, $f1
160+
; MIPS32R6-NEXT: max.s $f0, $f0, $f1
161+
; MIPS32R6-NEXT: min.s $f1, $f14, $f14
162+
; MIPS32R6-NEXT: mtc1 $7, $f2
163+
; MIPS32R6-NEXT: min.s $f2, $f2, $f2
164+
; MIPS32R6-NEXT: jr $ra
165+
; MIPS32R6-NEXT: max.s $f2, $f1, $f2
166+
;
167+
; MIPS64R6-LABEL: mQ:
168+
; MIPS64R6: # %bb.0: # %entry
169+
; MIPS64R6-NEXT: min.s $f0, $f14, $f14
170+
; MIPS64R6-NEXT: min.s $f1, $f12, $f12
171+
; MIPS64R6-NEXT: max.s $f0, $f1, $f0
172+
; MIPS64R6-NEXT: min.s $f1, $f15, $f15
173+
; MIPS64R6-NEXT: min.s $f2, $f13, $f13
174+
; MIPS64R6-NEXT: jr $ra
175+
; MIPS64R6-NEXT: max.s $f2, $f2, $f1
176+
entry:
177+
%a0f0 = extractvalue [2 x float] %a0, 0
178+
%a0f1 = extractvalue [2 x float] %a0, 1
179+
%a1f0 = extractvalue [2 x float] %a1, 0
180+
%a1f1 = extractvalue [2 x float] %a1, 1
181+
%max0 = tail call float @llvm.maximumnum.f32(float %a0f0, float %a1f0)
182+
%max1 = tail call float @llvm.maximumnum.f32(float %a0f1, float %a1f1)
183+
%ret0 = insertvalue %struct.f2 poison, float %max0, 0
184+
%ret1 = insertvalue %struct.f2 %ret0, float %max1, 1
185+
ret %struct.f2 %ret1
186+
}

0 commit comments

Comments
 (0)