2019-07-16 02:18:46 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
|
|
; RUN: llc -global-isel -mtriple=amdgcn--amdhsa -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
|
|
|
|
|
|
|
|
define amdgpu_kernel void @test_wave64(i32 %arg0, i64 %saved) {
|
|
|
|
; GCN-LABEL: test_wave64:
|
|
|
|
; GCN: ; %bb.0: ; %entry
|
|
|
|
; GCN-NEXT: s_load_dword s2, s[4:5], 0x0
|
|
|
|
; GCN-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
|
|
|
|
; GCN-NEXT: s_waitcnt lgkmcnt(0)
|
2020-01-06 01:22:21 +08:00
|
|
|
; GCN-NEXT: s_cmp_lg_u32 s2, 0
|
AMDGPU/GlobalISel: Replace handling of boolean values
This solves selection failures with generated selection patterns,
which would fail due to inferring the SGPR reg bank for virtual
registers with a set register class instead of VCC bank. Use
instruction selection would constrain the virtual register to a
specific class, so when the def was selected later the bank no longer
was set to VCC.
Remove the SCC reg bank. SCC isn't directly addressable, so it
requires copying from SCC to an allocatable 32-bit register during
selection, so these might as well be treated as 32-bit SGPR values.
Now any scalar boolean value that will produce an outupt in SCC should
be widened during RegBankSelect to s32. Any s1 value should be a
vector boolean during selection. This makes the vcc register bank
unambiguous with a normal SGPR during selection.
Summary of how this should now work:
- G_TRUNC is always a no-op, and never should use a vcc bank result.
- SALU boolean operations should be promoted to s32 in RegBankSelect
apply mapping
- An s1 value means vcc bank at selection. The exception is for
legalization artifacts that use s1, which are never VCC. All other
contexts should infer the VCC register classes for s1 typed
registers. The LLT for the register is now needed to infer the
correct register class. Extensions with vcc sources should be
legalized to a select of constants during RegBankSelect.
- Copy from non-vcc to vcc ensures high bits of the input value are
cleared during selection.
- SALU boolean inputs should ensure the inputs are 0/1. This includes
select, conditional branches, and carry-ins.
There are a few somewhat dirty details. One is that G_TRUNC/G_*EXT
selection ignores the usual register-bank from register class
functions, and can't handle truncates with VCC result banks. I think
this is OK, since the artifacts are specially treated anyway. This
does require some care to avoid producing cases with vcc. There will
also be no 100% reliable way to verify this rule is followed in
selection in case of register classes, and violations manifests
themselves as invalid copy instructions much later.
Standard phi handling also only considers the bank of the result
register, and doesn't insert copies to make the source banks
match. This doesn't work for vcc, so we have to manually correct phi
inputs in this case. We should add a verifier check to make sure there
are no phis with mixed vcc and non-vcc register bank inputs.
There's also some duplication with the LegalizerHelper, and some code
which should live in the helper. I don't see a good way to share
special knowledge about what types to use for intermediate operations
depending on the bank for example. Using the helper to replace
extensions with selects also seems somewhat awkward to me.
Another issue is there are some contexts calling
getRegBankFromRegClass that apparently don't have the LLT type for the
register, but I haven't yet run into a real issue from this.
This also introduces new unnecessary instructions in most cases, since
we don't yet try to optimize out the zext when the source is known to
come from a compare.
2019-11-03 00:30:59 +08:00
|
|
|
; GCN-NEXT: s_cselect_b32 s2, 1, 0
|
|
|
|
; GCN-NEXT: s_and_b32 s2, s2, 1
|
|
|
|
; GCN-NEXT: s_cmp_lg_u32 s2, 0
|
2020-01-06 01:22:21 +08:00
|
|
|
; GCN-NEXT: s_cbranch_scc1 BB0_2
|
2019-07-16 02:18:46 +08:00
|
|
|
; GCN-NEXT: ; %bb.1: ; %mid
|
|
|
|
; GCN-NEXT: v_mov_b32_e32 v0, 0
|
2019-07-17 02:42:53 +08:00
|
|
|
; GCN-NEXT: global_store_dword v[0:1], v0, off
|
2019-07-16 02:18:46 +08:00
|
|
|
; GCN-NEXT: BB0_2: ; %bb
|
|
|
|
; GCN-NEXT: s_or_b64 exec, exec, s[0:1]
|
|
|
|
; GCN-NEXT: v_mov_b32_e32 v0, 0
|
2019-07-17 02:42:53 +08:00
|
|
|
; GCN-NEXT: global_store_dword v[0:1], v0, off
|
2019-07-16 02:18:46 +08:00
|
|
|
; GCN-NEXT: s_endpgm
|
|
|
|
entry:
|
|
|
|
%cond = icmp eq i32 %arg0, 0
|
|
|
|
br i1 %cond, label %mid, label %bb
|
|
|
|
|
|
|
|
mid:
|
|
|
|
store volatile i32 0, i32 addrspace(1)* undef
|
|
|
|
br label %bb
|
|
|
|
|
|
|
|
bb:
|
|
|
|
call void @llvm.amdgcn.end.cf.i64(i64 %saved)
|
|
|
|
store volatile i32 0, i32 addrspace(1)* undef
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @llvm.amdgcn.end.cf.i64(i64 %val)
|