Skip to content

Commit aa50b93

Browse files
committed
[AMDGPU][GlobalISel] Add more sign/zero/any-extension tests
Add s1 to s16 cases, and for sgprs s1 to s64 and s32 to s64.
1 parent 906ebd5 commit aa50b93

File tree

3 files changed

+186
-0
lines changed

3 files changed

+186
-0
lines changed

llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-anyext.mir

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,26 @@ body: |
129129

130130
---
131131

132+
name: anyext_sgpr_s1_to_sgpr_s16
133+
legalized: true
134+
regBankSelected: true
135+
body: |
136+
bb.0:
137+
liveins: $sgpr0
138+
139+
; GCN-LABEL: name: anyext_sgpr_s1_to_sgpr_s16
140+
; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
141+
; GCN-NEXT: [[S_BFE_U32_:%[0-9]+]]:sreg_32 = S_BFE_U32 [[COPY]], 1048576, implicit-def $scc
142+
; GCN-NEXT: $sgpr0 = COPY [[S_BFE_U32_]]
143+
%0:sgpr(s32) = COPY $sgpr0
144+
%1:sgpr(s1) = G_TRUNC %0
145+
%2:sgpr(s16) = G_ANYEXT %1
146+
%3:sgpr(s32) = G_ZEXT %2
147+
$sgpr0 = COPY %3
148+
...
149+
150+
---
151+
132152
name: anyext_sgpr_s1_to_sgpr_s32
133153
legalized: true
134154
regBankSelected: true
@@ -147,6 +167,46 @@ body: |
147167

148168
---
149169

170+
name: anyext_sgpr_s1_to_sgpr_s64
171+
legalized: true
172+
regBankSelected: true
173+
body: |
174+
bb.0:
175+
liveins: $sgpr0
176+
177+
; GCN-LABEL: name: anyext_sgpr_s1_to_sgpr_s64
178+
; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
179+
; GCN-NEXT: [[DEF:%[0-9]+]]:sreg_32 = IMPLICIT_DEF
180+
; GCN-NEXT: [[REG_SEQUENCE:%[0-9]+]]:sreg_64 = REG_SEQUENCE [[COPY]], %subreg.sub0, [[DEF]], %subreg.sub1
181+
; GCN-NEXT: $sgpr0_sgpr1 = COPY [[REG_SEQUENCE]]
182+
%0:sgpr(s32) = COPY $sgpr0
183+
%1:sgpr(s1) = G_TRUNC %0
184+
%2:sgpr(s64) = G_ANYEXT %1
185+
$sgpr0_sgpr1 = COPY %2
186+
...
187+
188+
---
189+
190+
name: anyext_vgpr_s1_to_vgpr_s16
191+
legalized: true
192+
regBankSelected: true
193+
body: |
194+
bb.0:
195+
liveins: $vgpr0
196+
197+
; GCN-LABEL: name: anyext_vgpr_s1_to_vgpr_s16
198+
; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
199+
; GCN-NEXT: [[V_BFE_U32_e64_:%[0-9]+]]:vgpr_32 = V_BFE_U32_e64 [[COPY]], 0, 16, implicit $exec
200+
; GCN-NEXT: $vgpr0 = COPY [[V_BFE_U32_e64_]]
201+
%0:vgpr(s32) = COPY $vgpr0
202+
%1:vgpr(s1) = G_TRUNC %0
203+
%2:vgpr(s16) = G_ANYEXT %1
204+
%3:vgpr(s32) = G_ZEXT %2
205+
$vgpr0 = COPY %3
206+
...
207+
208+
---
209+
150210
name: anyext_vgpr_s1_to_vgpr_s32
151211
legalized: true
152212
regBankSelected: true

llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-sext.mir

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@
33

44
---
55

6+
name: sext_sgpr_s1_to_sgpr_s16
7+
legalized: true
8+
regBankSelected: true
9+
body: |
10+
bb.0:
11+
liveins: $sgpr0
12+
13+
; GCN-LABEL: name: sext_sgpr_s1_to_sgpr_s16
14+
; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
15+
; GCN-NEXT: [[S_BFE_I32_:%[0-9]+]]:sreg_32 = S_BFE_I32 [[COPY]], 65536, implicit-def $scc
16+
; GCN-NEXT: [[S_BFE_U32_:%[0-9]+]]:sreg_32 = S_BFE_U32 [[S_BFE_I32_]], 1048576, implicit-def $scc
17+
; GCN-NEXT: $sgpr0 = COPY [[S_BFE_U32_]]
18+
%0:sgpr(s32) = COPY $sgpr0
19+
%1:sgpr(s1) = G_TRUNC %0
20+
%2:sgpr(s16) = G_SEXT %1
21+
%3:sgpr(s32) = G_ZEXT %2
22+
$sgpr0 = COPY %3
23+
...
24+
25+
---
26+
627
name: sext_sgpr_s1_to_sgpr_s32
728
legalized: true
829
regBankSelected: true
@@ -83,6 +104,27 @@ body: |
83104
84105
...
85106

107+
---
108+
109+
name: sext_sgpr_s32_to_sgpr_s64
110+
legalized: true
111+
regBankSelected: true
112+
body: |
113+
bb.0:
114+
liveins: $sgpr0
115+
116+
; GCN-LABEL: name: sext_sgpr_s32_to_sgpr_s64
117+
; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
118+
; GCN-NEXT: [[DEF:%[0-9]+]]:sreg_32 = IMPLICIT_DEF
119+
; GCN-NEXT: [[REG_SEQUENCE:%[0-9]+]]:sreg_64 = REG_SEQUENCE [[COPY]], %subreg.sub0, [[DEF]], %subreg.sub1
120+
; GCN-NEXT: [[S_BFE_I64_:%[0-9]+]]:sreg_64 = S_BFE_I64 [[REG_SEQUENCE]], 2097152, implicit-def $scc
121+
; GCN-NEXT: $sgpr0_sgpr1 = COPY [[S_BFE_I64_]]
122+
%0:sgpr(s32) = COPY $sgpr0
123+
%1:sgpr(s64) = G_SEXT %0
124+
$sgpr0_sgpr1 = COPY %1
125+
126+
...
127+
86128
# ---
87129

88130
# name: sext_vcc_s1_to_vgpr_s32
@@ -100,6 +142,27 @@ body: |
100142

101143
---
102144

145+
name: sext_vgpr_s1_to_vgpr_s16
146+
legalized: true
147+
regBankSelected: true
148+
body: |
149+
bb.0:
150+
liveins: $vgpr0
151+
152+
; GCN-LABEL: name: sext_vgpr_s1_to_vgpr_s16
153+
; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
154+
; GCN-NEXT: [[V_BFE_I32_e64_:%[0-9]+]]:vgpr_32 = V_BFE_I32_e64 [[COPY]], 0, 1, implicit $exec
155+
; GCN-NEXT: [[V_BFE_U32_e64_:%[0-9]+]]:vgpr_32 = V_BFE_U32_e64 [[V_BFE_I32_e64_]], 0, 16, implicit $exec
156+
; GCN-NEXT: $vgpr0 = COPY [[V_BFE_U32_e64_]]
157+
%0:vgpr(s32) = COPY $vgpr0
158+
%1:vgpr(s1) = G_TRUNC %0
159+
%2:vgpr(s16) = G_SEXT %1
160+
%3:vgpr(s32) = G_ZEXT %2
161+
$vgpr0 = COPY %3
162+
...
163+
164+
---
165+
103166
name: sext_vgpr_s1_to_vgpr_s32
104167
legalized: true
105168
regBankSelected: true

llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-zext.mir

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@
33

44
---
55

6+
name: zext_sgpr_s1_to_sgpr_s16
7+
legalized: true
8+
regBankSelected: true
9+
body: |
10+
bb.0:
11+
liveins: $sgpr0
12+
13+
; GCN-LABEL: name: zext_sgpr_s1_to_sgpr_s16
14+
; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
15+
; GCN-NEXT: [[S_AND_B32_:%[0-9]+]]:sreg_32 = S_AND_B32 [[COPY]], 1, implicit-def $scc
16+
; GCN-NEXT: [[S_SEXT_I32_I16_:%[0-9]+]]:sreg_32 = S_SEXT_I32_I16 [[S_AND_B32_]]
17+
; GCN-NEXT: $sgpr0 = COPY [[S_SEXT_I32_I16_]]
18+
%0:sgpr(s32) = COPY $sgpr0
19+
%1:sgpr(s1) = G_TRUNC %0
20+
%2:sgpr(s16) = G_ZEXT %1
21+
%3:sgpr(s32) = G_SEXT %2
22+
$sgpr0 = COPY %3
23+
...
24+
25+
---
26+
627
name: zext_sgpr_s1_to_sgpr_s32
728
legalized: true
829
regBankSelected: true
@@ -83,6 +104,27 @@ body: |
83104
84105
...
85106

107+
---
108+
109+
name: zext_sgpr_s32_to_sgpr_s64
110+
legalized: true
111+
regBankSelected: true
112+
body: |
113+
bb.0:
114+
liveins: $sgpr0
115+
116+
; GCN-LABEL: name: zext_sgpr_s32_to_sgpr_s64
117+
; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
118+
; GCN-NEXT: [[DEF:%[0-9]+]]:sreg_32 = IMPLICIT_DEF
119+
; GCN-NEXT: [[REG_SEQUENCE:%[0-9]+]]:sreg_64 = REG_SEQUENCE [[COPY]], %subreg.sub0, [[DEF]], %subreg.sub1
120+
; GCN-NEXT: [[S_BFE_U64_:%[0-9]+]]:sreg_64 = S_BFE_U64 [[REG_SEQUENCE]], 2097152, implicit-def $scc
121+
; GCN-NEXT: $sgpr0_sgpr1 = COPY [[S_BFE_U64_]]
122+
%0:sgpr(s32) = COPY $sgpr0
123+
%1:sgpr(s64) = G_ZEXT %0
124+
$sgpr0_sgpr1 = COPY %1
125+
126+
...
127+
86128
# ---
87129

88130
# name: zext_vcc_s1_to_vgpr_s32
@@ -100,6 +142,27 @@ body: |
100142

101143
---
102144

145+
name: zext_vgpr_s1_to_vgpr_s16
146+
legalized: true
147+
regBankSelected: true
148+
body: |
149+
bb.0:
150+
liveins: $vgpr0
151+
152+
; GCN-LABEL: name: zext_vgpr_s1_to_vgpr_s16
153+
; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
154+
; GCN-NEXT: [[V_AND_B32_e32_:%[0-9]+]]:vgpr_32 = V_AND_B32_e32 1, [[COPY]], implicit $exec
155+
; GCN-NEXT: [[V_BFE_I32_e64_:%[0-9]+]]:vgpr_32 = V_BFE_I32_e64 [[V_AND_B32_e32_]], 0, 16, implicit $exec
156+
; GCN-NEXT: $vgpr0 = COPY [[V_BFE_I32_e64_]]
157+
%0:vgpr(s32) = COPY $vgpr0
158+
%1:vgpr(s1) = G_TRUNC %0
159+
%2:vgpr(s16) = G_ZEXT %1
160+
%3:vgpr(s32) = G_SEXT %2
161+
$vgpr0 = COPY %3
162+
...
163+
164+
---
165+
103166
name: zext_vgpr_s1_to_vgpr_s32
104167
legalized: true
105168
regBankSelected: true

0 commit comments

Comments
 (0)