Skip to content

Commit 6c6a477

Browse files
committed
added sgpr test
1 parent 41b069e commit 6c6a477

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,8 @@ bool SIShrinkInstructions::shouldSwapCndOperands(
974974
if (!Src1Imm && Src0Imm)
975975
InstsToSwap--;
976976
else if (Src1Imm && !Src0Imm &&
977-
UseInst->getOperand(1).getImm() == SISrcMods::NONE)
977+
UseInst->getOperand(1).getImm() == SISrcMods::NONE &&
978+
TRI->isVGPR(*MRI, Src0.getReg()))
978979
InstsToSwap++;
979980
}
980981
return (InstsToSwap > 0);

llvm/test/CodeGen/AMDGPU/shrink-cndmask.ll

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,27 @@ define amdgpu_cs void @test_mixed(i32 %a, i32 %p, i32 %q, i32 %r, i32 %s, ptr ad
203203
ret void
204204
}
205205

206+
define amdgpu_cs void @test_sgpr(i32 %a, i32 %p, i32 inreg %q, i32 inreg %r, ptr addrspace(1) %out) {
207+
; GCN-LABEL: test_sgpr:
208+
; GCN: ; %bb.0: ; %.entry
209+
; GCN-NEXT: v_cmp_eq_u32_e32 vcc_lo, -1, v0
210+
; GCN-NEXT: v_cndmask_b32_e32 v4, 0, v1, vcc_lo
211+
; GCN-NEXT: v_cndmask_b32_e64 v5, s0, 0, vcc_lo
212+
; GCN-NEXT: v_cndmask_b32_e64 v6, s1, 0, vcc_lo
213+
; GCN-NEXT: global_store_b96 v[2:3], v[4:6], off
214+
; GCN-NEXT: s_endpgm
215+
.entry:
216+
%vcc = icmp eq i32 %a, -1
217+
%val1 = select i1 %vcc, i32 %p, i32 0
218+
%val2 = select i1 %vcc, i32 0, i32 %q
219+
%val3 = select i1 %vcc, i32 0, i32 %r
220+
%ret0 = insertelement <3 x i32> poison, i32 %val1, i32 0
221+
%ret1 = insertelement <3 x i32> %ret0, i32 %val2, i32 1
222+
%ret2 = insertelement <3 x i32> %ret1, i32 %val3, i32 2
223+
store <3 x i32> %ret2, ptr addrspace(1) %out
224+
ret void
225+
}
226+
206227
define amdgpu_cs void @test_u32_ne(i32 %a, i32 %p, i32 %q, ptr addrspace(1) %out) {
207228
; GCN-LABEL: test_u32_ne:
208229
; GCN: ; %bb.0: ; %.entry

0 commit comments

Comments
 (0)