mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
2b0231f519
This replaces most argument uses with loads, but for now not all. The code in SelectionDAG for calling convention lowering is actively harmful for amdgpu_kernel. It attempts to split the argument types into register legal types, which results in low quality code for arbitary types. Since all kernel arguments are passed in memory, we just want the raw types. I've tried a couple of methods of mitigating this in SelectionDAG, but it's easier to just bypass this problem alltogether. It's possible to hack around the problem in the initial lowering, but the real problem is the DAG then expects to be able to use CopyToReg/CopyFromReg for uses of the arguments outside the block. Exposing the argument loads in the IR also has the advantage that the LoadStoreVectorizer can merge them. I'm not sure the best approach to dealing with the IR argument list is. The patch as-is just leaves the IR arguments in place, so all the existing code will still compute the same kernarg size and pointlessly lowers the arguments. Arguably the frontend should emit kernels with an empty argument list in the first place. Alternatively a dummy array could be inserted as a single argument just to reserve space. This does have some disadvantages. Local pointer kernel arguments can no longer have AssertZext placed on them as the equivalent !range metadata is not valid on pointer typed loads. This is mostly bad for SI which needs to know about the known bits in order to use the DS instruction offset, so in this case this is not done. More importantly, this skips noalias arguments since this pass does not yet convert this to the equivalent !alias.scope and !noalias metadata. Producing this metadata correctly seems to be tricky, although this logically is the same as inlining into a function which doesn't exist. Additionally, exposing these loads to the vectorizer may result in degraded aliasing information if a pointer load is merged with another argument load. I'm also not entirely sure this is preserving the current clover ABI, although I would greatly prefer if it would stop widening arguments and match the HSA ABI. As-is I think it is extending < 4-byte arguments to 4-bytes but doesn't align them to 4-bytes. llvm-svn: 335650
121 lines
3.0 KiB
LLVM
121 lines
3.0 KiB
LLVM
; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=GCN -check-prefix=SI %s
|
|
; RUN: llc -march=amdgcn -mcpu=fiji -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=GCN -check-prefix=VI %s
|
|
|
|
; GCN-LABEL: {{^}}br_cc_f16:
|
|
; GCN: buffer_load_ushort v[[A_F16:[0-9]+]]
|
|
; GCN: buffer_load_ushort v[[B_F16:[0-9]+]]
|
|
|
|
; SI: v_cvt_f32_f16_e32 v[[A_F32:[0-9]+]], v[[A_F16]]
|
|
; SI: v_cvt_f32_f16_e32 v[[B_F32:[0-9]+]], v[[B_F16]]
|
|
; SI: v_cmp_nlt_f32_e32 vcc, v[[A_F32]], v[[B_F32]]
|
|
; VI: v_cmp_nlt_f16_e32 vcc, v[[A_F16]], v[[B_F16]]
|
|
; GCN: s_cbranch_vccnz
|
|
|
|
; SI: one{{$}}
|
|
; SI: v_cvt_f16_f32_e32 v[[CVT:[0-9]+]], v[[A_F32]]
|
|
|
|
; SI: two{{$}}
|
|
; SI: v_cvt_f16_f32_e32 v[[CVT]], v[[B_F32]]
|
|
|
|
; SI: one{{$}}
|
|
; SI: buffer_store_short v[[CVT]]
|
|
; SI: s_endpgm
|
|
|
|
|
|
|
|
; VI: one{{$}}
|
|
; VI: buffer_store_short v[[A_F16]]
|
|
; VI: s_endpgm
|
|
|
|
; VI: two{{$}}
|
|
; VI: buffer_store_short v[[B_F16]]
|
|
; VI: s_endpgm
|
|
define amdgpu_kernel void @br_cc_f16(
|
|
half addrspace(1)* %r,
|
|
half addrspace(1)* %a,
|
|
half addrspace(1)* %b) {
|
|
entry:
|
|
%a.val = load volatile half, half addrspace(1)* %a
|
|
%b.val = load volatile half, half addrspace(1)* %b
|
|
%fcmp = fcmp olt half %a.val, %b.val
|
|
br i1 %fcmp, label %one, label %two
|
|
|
|
one:
|
|
store half %a.val, half addrspace(1)* %r
|
|
ret void
|
|
|
|
two:
|
|
store half %b.val, half addrspace(1)* %r
|
|
ret void
|
|
}
|
|
|
|
; GCN-LABEL: {{^}}br_cc_f16_imm_a:
|
|
; GCN: buffer_load_ushort v[[B_F16:[0-9]+]]
|
|
|
|
; SI: v_cvt_f32_f16_e32 v[[B_F32:[0-9]+]], v[[B_F16]]
|
|
; SI: v_cmp_nlt_f32_e32 vcc, 0.5, v[[B_F32]]
|
|
; SI: s_cbranch_vccnz
|
|
|
|
; VI: v_cmp_nlt_f16_e32 vcc, 0.5, v[[B_F16]]
|
|
; VI: s_cbranch_vccnz
|
|
|
|
; GCN: one{{$}}
|
|
; GCN: v_mov_b32_e32 v[[A_F16:[0-9]+]], 0x380{{0|1}}{{$}}
|
|
|
|
; SI: buffer_store_short v[[A_F16]]
|
|
; SI: s_endpgm
|
|
|
|
|
|
; GCN: two{{$}}
|
|
; SI: v_cvt_f16_f32_e32 v[[B_F16:[0-9]+]], v[[B_F32]]
|
|
|
|
define amdgpu_kernel void @br_cc_f16_imm_a(
|
|
half addrspace(1)* %r,
|
|
half addrspace(1)* %b) {
|
|
entry:
|
|
%b.val = load half, half addrspace(1)* %b
|
|
%fcmp = fcmp olt half 0xH3800, %b.val
|
|
br i1 %fcmp, label %one, label %two
|
|
|
|
one:
|
|
store half 0xH3800, half addrspace(1)* %r
|
|
ret void
|
|
|
|
two:
|
|
store half %b.val, half addrspace(1)* %r
|
|
ret void
|
|
}
|
|
|
|
; GCN-LABEL: {{^}}br_cc_f16_imm_b:
|
|
; GCN: buffer_load_ushort v[[A_F16:[0-9]+]]
|
|
|
|
; SI: v_cvt_f32_f16_e32 v[[A_F32:[0-9]+]], v[[A_F16]]
|
|
; SI: v_cmp_ngt_f32_e32 vcc, 0.5, v[[A_F32]]
|
|
|
|
; VI: v_cmp_ngt_f16_e32 vcc, 0.5, v[[A_F16]]
|
|
; GCN: s_cbranch_vccnz
|
|
|
|
; GCN: one{{$}}
|
|
; SI: v_cvt_f16_f32_e32 v[[A_F16:[0-9]+]], v[[A_F32]]
|
|
|
|
; GCN: two{{$}}
|
|
; GCN: v_mov_b32_e32 v[[B_F16:[0-9]+]], 0x3800{{$}}
|
|
; GCN: buffer_store_short v[[B_F16]]
|
|
; GCN: s_endpgm
|
|
define amdgpu_kernel void @br_cc_f16_imm_b(
|
|
half addrspace(1)* %r,
|
|
half addrspace(1)* %a) {
|
|
entry:
|
|
%a.val = load half, half addrspace(1)* %a
|
|
%fcmp = fcmp olt half %a.val, 0xH3800
|
|
br i1 %fcmp, label %one, label %two
|
|
|
|
one:
|
|
store half %a.val, half addrspace(1)* %r
|
|
ret void
|
|
|
|
two:
|
|
store half 0xH3800, half addrspace(1)* %r
|
|
ret void
|
|
}
|