Skip to content

Commit 1918369

Browse files
authored
[RISCV][GISel] Add missing fclass tests. NFC (#96694)
We were only testing f32 on rv32 and f64 on rv64. We need to test f32 and f64 on both rv32 and rv64.
1 parent 2612765 commit 1918369

File tree

6 files changed

+258
-0
lines changed

6 files changed

+258
-0
lines changed

llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/is-fpclass-rv32.mir

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,81 @@ body: |
8080
$x10 = COPY %7(s32)
8181
PseudoRET implicit $x10
8282
...
83+
---
84+
name: is_fpclass_f64
85+
legalized: true
86+
regBankSelected: true
87+
body: |
88+
bb.0:
89+
liveins: $f10_d
90+
91+
; CHECK-LABEL: name: is_fpclass_f64
92+
; CHECK: liveins: $f10_d
93+
; CHECK-NEXT: {{ $}}
94+
; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr64 = COPY $f10_d
95+
; CHECK-NEXT: [[FCLASS_D:%[0-9]+]]:gpr = FCLASS_D [[COPY]]
96+
; CHECK-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[FCLASS_D]], 152
97+
; CHECK-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[ANDI]]
98+
; CHECK-NEXT: $x10 = COPY [[SLTU]]
99+
; CHECK-NEXT: PseudoRET implicit $x10
100+
%0:fprb(s64) = COPY $f10_d
101+
%3:gprb(s32) = G_CONSTANT i32 152
102+
%4:gprb(s32) = G_CONSTANT i32 0
103+
%5:gprb(s32) = G_FCLASS %0(s64)
104+
%6:gprb(s32) = G_AND %5, %3
105+
%7:gprb(s32) = G_ICMP intpred(ne), %6(s32), %4
106+
$x10 = COPY %7(s32)
107+
PseudoRET implicit $x10
108+
...
109+
---
110+
name: is_fpclass_f64_onehot
111+
legalized: true
112+
regBankSelected: true
113+
body: |
114+
bb.0:
115+
liveins: $f10_d
116+
117+
; CHECK-LABEL: name: is_fpclass_f64_onehot
118+
; CHECK: liveins: $f10_d
119+
; CHECK-NEXT: {{ $}}
120+
; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr64 = COPY $f10_d
121+
; CHECK-NEXT: [[FCLASS_D:%[0-9]+]]:gpr = FCLASS_D [[COPY]]
122+
; CHECK-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[FCLASS_D]], 256
123+
; CHECK-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[ANDI]]
124+
; CHECK-NEXT: $x10 = COPY [[SLTU]]
125+
; CHECK-NEXT: PseudoRET implicit $x10
126+
%0:fprb(s64) = COPY $f10_d
127+
%3:gprb(s32) = G_CONSTANT i32 256
128+
%4:gprb(s32) = G_CONSTANT i32 0
129+
%5:gprb(s32) = G_FCLASS %0(s64)
130+
%6:gprb(s32) = G_AND %5, %3
131+
%7:gprb(s32) = G_ICMP intpred(ne), %6(s32), %4
132+
$x10 = COPY %7(s32)
133+
PseudoRET implicit $x10
134+
...
135+
---
136+
name: is_fpclass_f64_one
137+
legalized: true
138+
regBankSelected: true
139+
body: |
140+
bb.0:
141+
liveins: $f10_d
142+
143+
; CHECK-LABEL: name: is_fpclass_f64_one
144+
; CHECK: liveins: $f10_d
145+
; CHECK-NEXT: {{ $}}
146+
; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr64 = COPY $f10_d
147+
; CHECK-NEXT: [[FCLASS_D:%[0-9]+]]:gpr = FCLASS_D [[COPY]]
148+
; CHECK-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[FCLASS_D]], 1
149+
; CHECK-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[ANDI]]
150+
; CHECK-NEXT: $x10 = COPY [[SLTU]]
151+
; CHECK-NEXT: PseudoRET implicit $x10
152+
%0:fprb(s64) = COPY $f10_d
153+
%3:gprb(s32) = G_CONSTANT i32 1
154+
%4:gprb(s32) = G_CONSTANT i32 0
155+
%5:gprb(s32) = G_FCLASS %0(s64)
156+
%6:gprb(s32) = G_AND %5, %3
157+
%7:gprb(s32) = G_ICMP intpred(ne), %6(s32), %4
158+
$x10 = COPY %7(s32)
159+
PseudoRET implicit $x10
160+
...

llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/is-fpclass-rv64.mir

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,84 @@
22
# RUN: llc -mtriple=riscv64 -mattr=+d -run-pass=instruction-select -verify-machineinstrs %s -o - | \
33
# RUN: FileCheck %s
44

5+
---
6+
name: is_fpclass_f32
7+
legalized: true
8+
regBankSelected: true
9+
body: |
10+
bb.0:
11+
liveins: $f10_f
12+
13+
; CHECK-LABEL: name: is_fpclass_f32
14+
; CHECK: liveins: $f10_f
15+
; CHECK-NEXT: {{ $}}
16+
; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr32 = COPY $f10_f
17+
; CHECK-NEXT: [[FCLASS_S:%[0-9]+]]:gpr = FCLASS_S [[COPY]]
18+
; CHECK-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[FCLASS_S]], 152
19+
; CHECK-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[ANDI]]
20+
; CHECK-NEXT: $x10 = COPY [[SLTU]]
21+
; CHECK-NEXT: PseudoRET implicit $x10
22+
%0:fprb(s32) = COPY $f10_f
23+
%3:gprb(s64) = G_CONSTANT i64 152
24+
%4:gprb(s64) = G_CONSTANT i64 0
25+
%5:gprb(s64) = G_FCLASS %0(s32)
26+
%6:gprb(s64) = G_AND %5, %3
27+
%7:gprb(s64) = G_ICMP intpred(ne), %6(s64), %4
28+
$x10 = COPY %7(s64)
29+
PseudoRET implicit $x10
30+
...
31+
---
32+
name: is_fpclass_f32_onehot
33+
legalized: true
34+
regBankSelected: true
35+
body: |
36+
bb.0:
37+
liveins: $f10_f
38+
39+
; CHECK-LABEL: name: is_fpclass_f32_onehot
40+
; CHECK: liveins: $f10_f
41+
; CHECK-NEXT: {{ $}}
42+
; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr32 = COPY $f10_f
43+
; CHECK-NEXT: [[FCLASS_S:%[0-9]+]]:gpr = FCLASS_S [[COPY]]
44+
; CHECK-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[FCLASS_S]], 256
45+
; CHECK-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[ANDI]]
46+
; CHECK-NEXT: $x10 = COPY [[SLTU]]
47+
; CHECK-NEXT: PseudoRET implicit $x10
48+
%0:fprb(s32) = COPY $f10_f
49+
%3:gprb(s64) = G_CONSTANT i64 256
50+
%4:gprb(s64) = G_CONSTANT i64 0
51+
%5:gprb(s64) = G_FCLASS %0(s32)
52+
%6:gprb(s64) = G_AND %5, %3
53+
%7:gprb(s64) = G_ICMP intpred(ne), %6(s64), %4
54+
$x10 = COPY %7(s64)
55+
PseudoRET implicit $x10
56+
...
57+
---
58+
name: is_fpclass_f32_one
59+
legalized: true
60+
regBankSelected: true
61+
body: |
62+
bb.0:
63+
liveins: $f10_f
64+
65+
; CHECK-LABEL: name: is_fpclass_f32_one
66+
; CHECK: liveins: $f10_f
67+
; CHECK-NEXT: {{ $}}
68+
; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr32 = COPY $f10_f
69+
; CHECK-NEXT: [[FCLASS_S:%[0-9]+]]:gpr = FCLASS_S [[COPY]]
70+
; CHECK-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[FCLASS_S]], 1
71+
; CHECK-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[ANDI]]
72+
; CHECK-NEXT: $x10 = COPY [[SLTU]]
73+
; CHECK-NEXT: PseudoRET implicit $x10
74+
%0:fprb(s32) = COPY $f10_f
75+
%3:gprb(s64) = G_CONSTANT i64 1
76+
%4:gprb(s64) = G_CONSTANT i64 0
77+
%5:gprb(s64) = G_FCLASS %0(s32)
78+
%6:gprb(s64) = G_AND %5, %3
79+
%7:gprb(s64) = G_ICMP intpred(ne), %6(s64), %4
80+
$x10 = COPY %7(s64)
81+
PseudoRET implicit $x10
82+
...
583
---
684
name: is_fpclass_f64
785
legalized: true

llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-is-fpclass-rv32.mir

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,27 @@ body: |
2626
PseudoRET implicit $x10
2727
2828
...
29+
---
30+
name: is_fpclass_f64
31+
body: |
32+
bb.1:
33+
liveins: $f10_d
34+
35+
; CHECK-LABEL: name: is_fpclass_f64
36+
; CHECK: liveins: $f10_d
37+
; CHECK-NEXT: {{ $}}
38+
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $f10_d
39+
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 152
40+
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
41+
; CHECK-NEXT: [[FCLASS:%[0-9]+]]:_(s32) = G_FCLASS [[COPY]](s64)
42+
; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[FCLASS]], [[C]]
43+
; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ne), [[AND]](s32), [[C1]]
44+
; CHECK-NEXT: $x10 = COPY [[ICMP]](s32)
45+
; CHECK-NEXT: PseudoRET implicit $x10
46+
%0:_(s64) = COPY $f10_d
47+
%1:_(s1) = G_IS_FPCLASS %0(s64), 608
48+
%2:_(s32) = G_ANYEXT %1(s1)
49+
$x10 = COPY %2(s32)
50+
PseudoRET implicit $x10
51+
52+
...

llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-is-fpclass-rv64.mir

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22
# RUN: llc -mtriple=riscv64 -mattr=+d -run-pass=legalizer %s -o - \
33
# RUN: | FileCheck %s
44

5+
---
6+
name: is_fpclass_f32
7+
body: |
8+
bb.1:
9+
liveins: $f10_f
10+
11+
; CHECK-LABEL: name: is_fpclass_f32
12+
; CHECK: liveins: $f10_f
13+
; CHECK-NEXT: {{ $}}
14+
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $f10_f
15+
; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 152
16+
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
17+
; CHECK-NEXT: [[FCLASS:%[0-9]+]]:_(s64) = G_FCLASS [[COPY]](s32)
18+
; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[FCLASS]], [[C]]
19+
; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s64) = G_ICMP intpred(ne), [[AND]](s64), [[C1]]
20+
; CHECK-NEXT: $x10 = COPY [[ICMP]](s64)
21+
; CHECK-NEXT: PseudoRET implicit $x10
22+
%0:_(s32) = COPY $f10_f
23+
%1:_(s1) = G_IS_FPCLASS %0(s32), 608
24+
%2:_(s64) = G_ANYEXT %1(s1)
25+
$x10 = COPY %2(s64)
26+
PseudoRET implicit $x10
27+
28+
...
529
---
630
name: is_fpclass_f64
731
body: |

llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/is-fpclass-rv32.mir

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,30 @@ body: |
2929
$x10 = COPY %7(s32)
3030
PseudoRET implicit $x10
3131
...
32+
---
33+
name: is_fpclass_f64
34+
legalized: true
35+
body: |
36+
bb.0:
37+
liveins: $f10_d
38+
39+
; CHECK-LABEL: name: is_fpclass_f64
40+
; CHECK: liveins: $f10_d
41+
; CHECK-NEXT: {{ $}}
42+
; CHECK-NEXT: [[COPY:%[0-9]+]]:fprb(s64) = COPY $f10_d
43+
; CHECK-NEXT: [[C:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 152
44+
; CHECK-NEXT: [[C1:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 0
45+
; CHECK-NEXT: [[FCLASS:%[0-9]+]]:gprb(s32) = G_FCLASS [[COPY]](s64)
46+
; CHECK-NEXT: [[AND:%[0-9]+]]:gprb(s32) = G_AND [[FCLASS]], [[C]]
47+
; CHECK-NEXT: [[ICMP:%[0-9]+]]:gprb(s32) = G_ICMP intpred(ne), [[AND]](s32), [[C1]]
48+
; CHECK-NEXT: $x10 = COPY [[ICMP]](s32)
49+
; CHECK-NEXT: PseudoRET implicit $x10
50+
%0:_(s64) = COPY $f10_d
51+
%3:_(s32) = G_CONSTANT i32 152
52+
%4:_(s32) = G_CONSTANT i32 0
53+
%5:_(s32) = G_FCLASS %0(s64)
54+
%6:_(s32) = G_AND %5, %3
55+
%7:_(s32) = G_ICMP intpred(ne), %6(s32), %4
56+
$x10 = COPY %7(s32)
57+
PseudoRET implicit $x10
58+
...

llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/is-fpclass-rv64.mir

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,33 @@
22
# RUN: llc -mtriple=riscv64 -mattr=+d -run-pass=regbankselect -verify-machineinstrs %s -o - \
33
# RUN: | FileCheck %s
44

5+
---
6+
name: is_fpclass_f32
7+
legalized: true
8+
body: |
9+
bb.0:
10+
liveins: $f10_f
11+
12+
; CHECK-LABEL: name: is_fpclass_f32
13+
; CHECK: liveins: $f10_f
14+
; CHECK-NEXT: {{ $}}
15+
; CHECK-NEXT: [[COPY:%[0-9]+]]:fprb(s32) = COPY $f10_f
16+
; CHECK-NEXT: [[C:%[0-9]+]]:gprb(s64) = G_CONSTANT i64 152
17+
; CHECK-NEXT: [[C1:%[0-9]+]]:gprb(s64) = G_CONSTANT i64 0
18+
; CHECK-NEXT: [[FCLASS:%[0-9]+]]:gprb(s64) = G_FCLASS [[COPY]](s32)
19+
; CHECK-NEXT: [[AND:%[0-9]+]]:gprb(s64) = G_AND [[FCLASS]], [[C]]
20+
; CHECK-NEXT: [[ICMP:%[0-9]+]]:gprb(s64) = G_ICMP intpred(ne), [[AND]](s64), [[C1]]
21+
; CHECK-NEXT: $x10 = COPY [[ICMP]](s64)
22+
; CHECK-NEXT: PseudoRET implicit $x10
23+
%0:_(s32) = COPY $f10_f
24+
%3:_(s64) = G_CONSTANT i64 152
25+
%4:_(s64) = G_CONSTANT i64 0
26+
%5:_(s64) = G_FCLASS %0(s32)
27+
%6:_(s64) = G_AND %5, %3
28+
%7:_(s64) = G_ICMP intpred(ne), %6(s64), %4
29+
$x10 = COPY %7(s64)
30+
PseudoRET implicit $x10
31+
...
532
---
633
name: is_fpclass_f64
734
legalized: true

0 commit comments

Comments
 (0)