Skip to content

Commit 78bf2e0

Browse files
committed
[AMDGPU] Update two Codegen tests. (NFC)
This change adds a new Codegen test with auto-generated checks and updates divergence-driven-trunc-to-i1.ll with auto-generated checks. This is in preparation to D118461 to visualize the Codegen changes.
1 parent 564f9be commit 78bf2e0

File tree

2 files changed

+281
-59
lines changed

2 files changed

+281
-59
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2+
; RUN: llc -march=amdgcn -mtriple=amdgcn-- -stop-after=amdgpu-isel -verify-machineinstrs -O0 < %s | FileCheck -check-prefix=GCN %s
3+
4+
define i32 @divergent_lshr_and_cmp(i32 %x) {
5+
; GCN-LABEL: name: divergent_lshr_and_cmp
6+
; GCN: bb.0.entry:
7+
; GCN-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
8+
; GCN-NEXT: liveins: $vgpr0, $sgpr30_sgpr31
9+
; GCN-NEXT: {{ $}}
10+
; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $sgpr30_sgpr31
11+
; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr0
12+
; GCN-NEXT: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 1
13+
; GCN-NEXT: [[V_LSHRREV_B32_e64_:%[0-9]+]]:vgpr_32 = V_LSHRREV_B32_e64 killed [[S_MOV_B32_]], [[COPY1]], implicit $exec
14+
; GCN-NEXT: [[V_AND_B32_e64_:%[0-9]+]]:vgpr_32 = V_AND_B32_e64 1, killed [[V_LSHRREV_B32_e64_]], implicit $exec
15+
; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64 = V_CMP_EQ_U32_e64 killed [[V_AND_B32_e64_]], 1, implicit $exec
16+
; GCN-NEXT: [[SI_IF:%[0-9]+]]:sreg_64 = SI_IF killed [[V_CMP_EQ_U32_e64_]], %bb.2, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
17+
; GCN-NEXT: S_BRANCH %bb.1
18+
; GCN-NEXT: {{ $}}
19+
; GCN-NEXT: bb.1.out.true:
20+
; GCN-NEXT: successors: %bb.2(0x80000000)
21+
; GCN-NEXT: {{ $}}
22+
; GCN-NEXT: [[S_MOV_B32_1:%[0-9]+]]:sreg_32 = S_MOV_B32 2
23+
; GCN-NEXT: [[V_LSHLREV_B32_e64_:%[0-9]+]]:vgpr_32 = V_LSHLREV_B32_e64 killed [[S_MOV_B32_1]], [[COPY1]], implicit $exec
24+
; GCN-NEXT: S_BRANCH %bb.2
25+
; GCN-NEXT: {{ $}}
26+
; GCN-NEXT: bb.2.UnifiedReturnBlock:
27+
; GCN-NEXT: [[PHI:%[0-9]+]]:vgpr_32 = PHI [[COPY1]], %bb.0, [[V_LSHLREV_B32_e64_]], %bb.1
28+
; GCN-NEXT: SI_END_CF [[SI_IF]], implicit-def dead $exec, implicit-def dead $scc, implicit $exec
29+
; GCN-NEXT: [[COPY2:%[0-9]+]]:ccr_sgpr_64 = COPY [[COPY]]
30+
; GCN-NEXT: $vgpr0 = COPY [[PHI]]
31+
; GCN-NEXT: [[COPY3:%[0-9]+]]:ccr_sgpr_64 = COPY [[COPY2]]
32+
; GCN-NEXT: S_SETPC_B64_return [[COPY3]], implicit $vgpr0
33+
entry:
34+
%0 = and i32 %x, 2
35+
%1 = icmp ne i32 %0, 0
36+
; Prevent removal of truncate in SDag by inserting llvm.amdgcn.if
37+
br i1 %1, label %out.true, label %out.else
38+
39+
out.true:
40+
%2 = shl i32 %x, 2
41+
ret i32 %2
42+
43+
out.else:
44+
ret i32 %x
45+
}
46+
47+
define amdgpu_kernel void @uniform_opt_lshr_and_cmp(i1 addrspace(1)* %out, i32 %x) {
48+
; GCN-LABEL: name: uniform_opt_lshr_and_cmp
49+
; GCN: bb.0.entry:
50+
; GCN-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
51+
; GCN-NEXT: liveins: $sgpr0_sgpr1
52+
; GCN-NEXT: {{ $}}
53+
; GCN-NEXT: [[COPY:%[0-9]+]]:sgpr_64(p4) = COPY $sgpr0_sgpr1
54+
; GCN-NEXT: [[S_LOAD_DWORDX2_IMM:%[0-9]+]]:sreg_64_xexec = S_LOAD_DWORDX2_IMM [[COPY]](p4), 9, 0 :: (dereferenceable invariant load (s64) from %ir.out.kernarg.offset.cast, align 4, addrspace 4)
55+
; GCN-NEXT: [[S_LOAD_DWORD_IMM:%[0-9]+]]:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM [[COPY]](p4), 11, 0 :: (dereferenceable invariant load (s32) from %ir.x.kernarg.offset.cast, addrspace 4)
56+
; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY [[S_LOAD_DWORDX2_IMM]]
57+
; GCN-NEXT: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 2
58+
; GCN-NEXT: [[S_AND_B32_:%[0-9]+]]:sreg_32 = S_AND_B32 [[S_LOAD_DWORD_IMM]], killed [[S_MOV_B32_]], implicit-def dead $scc
59+
; GCN-NEXT: [[S_MOV_B32_1:%[0-9]+]]:sreg_32 = S_MOV_B32 1
60+
; GCN-NEXT: [[S_LSHR_B32_:%[0-9]+]]:sreg_32 = S_LSHR_B32 [[S_LOAD_DWORD_IMM]], killed [[S_MOV_B32_1]], implicit-def dead $scc
61+
; GCN-NEXT: [[S_AND_B32_1:%[0-9]+]]:sreg_32 = S_AND_B32 1, killed [[S_LSHR_B32_]], implicit-def dead $scc
62+
; GCN-NEXT: S_CMP_EQ_U32 killed [[S_AND_B32_1]], 1, implicit-def $scc
63+
; GCN-NEXT: [[COPY2:%[0-9]+]]:sreg_64 = COPY $scc
64+
; GCN-NEXT: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[COPY2]]
65+
; GCN-NEXT: [[S_MOV_B32_2:%[0-9]+]]:sreg_32 = S_MOV_B32 0
66+
; GCN-NEXT: S_CMP_EQ_U32 killed [[S_AND_B32_]], killed [[S_MOV_B32_2]], implicit-def $scc
67+
; GCN-NEXT: S_CBRANCH_SCC1 %bb.2, implicit $scc
68+
; GCN-NEXT: S_BRANCH %bb.1
69+
; GCN-NEXT: {{ $}}
70+
; GCN-NEXT: bb.1.out.true:
71+
; GCN-NEXT: [[S_MOV_B64_:%[0-9]+]]:sreg_64 = S_MOV_B64 -1
72+
; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[COPY3]], killed [[S_MOV_B64_]], implicit-def dead $scc
73+
; GCN-NEXT: [[COPY4:%[0-9]+]]:sreg_32 = COPY [[COPY1]].sub1
74+
; GCN-NEXT: [[COPY5:%[0-9]+]]:sreg_32 = COPY [[COPY1]].sub0
75+
; GCN-NEXT: [[S_MOV_B32_3:%[0-9]+]]:sreg_32 = S_MOV_B32 61440
76+
; GCN-NEXT: [[S_MOV_B32_4:%[0-9]+]]:sreg_32 = S_MOV_B32 -1
77+
; GCN-NEXT: [[REG_SEQUENCE:%[0-9]+]]:sgpr_128 = REG_SEQUENCE killed [[COPY5]], %subreg.sub0, killed [[COPY4]], %subreg.sub1, killed [[S_MOV_B32_4]], %subreg.sub2, killed [[S_MOV_B32_3]], %subreg.sub3
78+
; GCN-NEXT: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, killed [[S_XOR_B64_]], implicit $exec
79+
; GCN-NEXT: BUFFER_STORE_BYTE_OFFSET killed [[V_CNDMASK_B32_e64_]], killed [[REG_SEQUENCE]], 0, 0, 0, 0, 0, implicit $exec :: (store (s8) into %ir.out.load, addrspace 1)
80+
; GCN-NEXT: S_ENDPGM 0
81+
; GCN-NEXT: {{ $}}
82+
; GCN-NEXT: bb.2.out.else:
83+
; GCN-NEXT: [[COPY6:%[0-9]+]]:sreg_32 = COPY [[COPY1]].sub1
84+
; GCN-NEXT: [[COPY7:%[0-9]+]]:sreg_32 = COPY [[COPY1]].sub0
85+
; GCN-NEXT: [[S_MOV_B32_5:%[0-9]+]]:sreg_32 = S_MOV_B32 61440
86+
; GCN-NEXT: [[S_MOV_B32_6:%[0-9]+]]:sreg_32 = S_MOV_B32 -1
87+
; GCN-NEXT: [[REG_SEQUENCE1:%[0-9]+]]:sgpr_128 = REG_SEQUENCE killed [[COPY7]], %subreg.sub0, killed [[COPY6]], %subreg.sub1, killed [[S_MOV_B32_6]], %subreg.sub2, killed [[S_MOV_B32_5]], %subreg.sub3
88+
; GCN-NEXT: [[V_CNDMASK_B32_e64_1:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, [[COPY3]], implicit $exec
89+
; GCN-NEXT: BUFFER_STORE_BYTE_OFFSET killed [[V_CNDMASK_B32_e64_1]], killed [[REG_SEQUENCE1]], 0, 0, 0, 0, 0, implicit $exec :: (store (s8) into %ir.out.load, addrspace 1)
90+
; GCN-NEXT: S_ENDPGM 0
91+
entry:
92+
%0 = and i32 %x, 2
93+
%1 = icmp ne i32 %0, 0
94+
; Don't optimize the truncate in the SDag away.
95+
br i1 %1, label %out.true, label %out.else
96+
97+
out.true:
98+
%2 = xor i1 %1, -1
99+
store i1 %2, i1 addrspace(1)* %out
100+
ret void
101+
102+
out.else:
103+
store i1 %1, i1 addrspace(1)* %out
104+
ret void
105+
}

0 commit comments

Comments
 (0)