2017-01-24 23:02:15 +01:00
|
|
|
; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC -check-prefix=GCN %s
|
|
|
|
; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefix=VI -check-prefix=FUNC -check-prefix=GCN %s
|
2014-07-15 17:51:09 +02:00
|
|
|
; RUN: llc -march=r600 -mcpu=cypress -verify-machineinstrs < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
|
2014-06-17 19:36:24 +02:00
|
|
|
|
2016-01-11 18:02:00 +01:00
|
|
|
declare i8 @llvm.ctlz.i8(i8, i1) nounwind readnone
|
|
|
|
|
2014-06-17 19:36:24 +02:00
|
|
|
declare i32 @llvm.ctlz.i32(i32, i1) nounwind readnone
|
|
|
|
declare <2 x i32> @llvm.ctlz.v2i32(<2 x i32>, i1) nounwind readnone
|
|
|
|
declare <4 x i32> @llvm.ctlz.v4i32(<4 x i32>, i1) nounwind readnone
|
|
|
|
|
2016-01-11 17:50:29 +01:00
|
|
|
declare i64 @llvm.ctlz.i64(i64, i1) nounwind readnone
|
|
|
|
declare <2 x i64> @llvm.ctlz.v2i64(<2 x i64>, i1) nounwind readnone
|
|
|
|
declare <4 x i64> @llvm.ctlz.v4i64(<4 x i64>, i1) nounwind readnone
|
|
|
|
|
2020-02-09 22:38:56 +01:00
|
|
|
declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
2016-01-11 17:50:29 +01:00
|
|
|
|
2014-10-01 19:15:17 +02:00
|
|
|
; FUNC-LABEL: {{^}}s_ctlz_zero_undef_i32:
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN: s_load_dword [[VAL:s[0-9]+]],
|
|
|
|
; GCN: s_flbit_i32_b32 [[SRESULT:s[0-9]+]], [[VAL]]
|
|
|
|
; GCN: v_mov_b32_e32 [[VRESULT:v[0-9]+]], [[SRESULT]]
|
|
|
|
; GCN: buffer_store_dword [[VRESULT]],
|
|
|
|
; GCN: s_endpgm
|
2014-07-15 17:51:09 +02:00
|
|
|
; EG: MEM_RAT_CACHELESS STORE_RAW [[RESULT:T[0-9]+\.[XYZW]]]
|
|
|
|
; EG: FFBH_UINT {{\*? *}}[[RESULT]]
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @s_ctlz_zero_undef_i32(i32 addrspace(1)* noalias %out, i32 %val) nounwind {
|
2014-06-17 19:36:24 +02:00
|
|
|
%ctlz = call i32 @llvm.ctlz.i32(i32 %val, i1 true) nounwind readnone
|
|
|
|
store i32 %ctlz, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 19:15:17 +02:00
|
|
|
; FUNC-LABEL: {{^}}v_ctlz_zero_undef_i32:
|
2017-07-04 19:32:00 +02:00
|
|
|
; GCN: {{buffer|flat}}_load_dword [[VAL:v[0-9]+]],
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN: v_ffbh_u32_e32 [[RESULT:v[0-9]+]], [[VAL]]
|
|
|
|
; GCN: buffer_store_dword [[RESULT]],
|
|
|
|
; GCN: s_endpgm
|
2014-07-15 17:51:09 +02:00
|
|
|
; EG: MEM_RAT_CACHELESS STORE_RAW [[RESULT:T[0-9]+\.[XYZW]]]
|
|
|
|
; EG: FFBH_UINT {{\*? *}}[[RESULT]]
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @v_ctlz_zero_undef_i32(i32 addrspace(1)* noalias %out, i32 addrspace(1)* noalias %valptr) nounwind {
|
2020-02-09 22:38:56 +01:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
2017-07-04 19:32:00 +02:00
|
|
|
%in.gep = getelementptr i32, i32 addrspace(1)* %valptr, i32 %tid
|
|
|
|
%val = load i32, i32 addrspace(1)* %in.gep, align 4
|
2014-06-17 19:36:24 +02:00
|
|
|
%ctlz = call i32 @llvm.ctlz.i32(i32 %val, i1 true) nounwind readnone
|
|
|
|
store i32 %ctlz, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 19:15:17 +02:00
|
|
|
; FUNC-LABEL: {{^}}v_ctlz_zero_undef_v2i32:
|
2017-07-04 19:32:00 +02:00
|
|
|
; GCN: {{buffer|flat}}_load_dwordx2
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN: v_ffbh_u32_e32
|
|
|
|
; GCN: v_ffbh_u32_e32
|
|
|
|
; GCN: buffer_store_dwordx2
|
|
|
|
; GCN: s_endpgm
|
2014-07-15 17:51:09 +02:00
|
|
|
; EG: MEM_RAT_CACHELESS STORE_RAW [[RESULT:T[0-9]+]]{{\.[XYZW]}}
|
|
|
|
; EG: FFBH_UINT {{\*? *}}[[RESULT]]
|
|
|
|
; EG: FFBH_UINT {{\*? *}}[[RESULT]]
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @v_ctlz_zero_undef_v2i32(<2 x i32> addrspace(1)* noalias %out, <2 x i32> addrspace(1)* noalias %valptr) nounwind {
|
2020-02-09 22:38:56 +01:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
2017-07-04 19:32:00 +02:00
|
|
|
%in.gep = getelementptr <2 x i32>, <2 x i32> addrspace(1)* %valptr, i32 %tid
|
|
|
|
%val = load <2 x i32>, <2 x i32> addrspace(1)* %in.gep, align 8
|
2014-06-17 19:36:24 +02:00
|
|
|
%ctlz = call <2 x i32> @llvm.ctlz.v2i32(<2 x i32> %val, i1 true) nounwind readnone
|
|
|
|
store <2 x i32> %ctlz, <2 x i32> addrspace(1)* %out, align 8
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 19:15:17 +02:00
|
|
|
; FUNC-LABEL: {{^}}v_ctlz_zero_undef_v4i32:
|
2017-07-04 19:32:00 +02:00
|
|
|
; GCN: {{buffer|flat}}_load_dwordx4
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN: v_ffbh_u32_e32
|
|
|
|
; GCN: v_ffbh_u32_e32
|
|
|
|
; GCN: v_ffbh_u32_e32
|
|
|
|
; GCN: v_ffbh_u32_e32
|
|
|
|
; GCN: buffer_store_dwordx4
|
|
|
|
; GCN: s_endpgm
|
2014-07-15 17:51:09 +02:00
|
|
|
; EG: MEM_RAT_CACHELESS STORE_RAW [[RESULT:T[0-9]+]]{{\.[XYZW]}}
|
|
|
|
; EG: FFBH_UINT {{\*? *}}[[RESULT]]
|
|
|
|
; EG: FFBH_UINT {{\*? *}}[[RESULT]]
|
|
|
|
; EG: FFBH_UINT {{\*? *}}[[RESULT]]
|
|
|
|
; EG: FFBH_UINT {{\*? *}}[[RESULT]]
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @v_ctlz_zero_undef_v4i32(<4 x i32> addrspace(1)* noalias %out, <4 x i32> addrspace(1)* noalias %valptr) nounwind {
|
2020-02-09 22:38:56 +01:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
2017-07-04 19:32:00 +02:00
|
|
|
%in.gep = getelementptr <4 x i32>, <4 x i32> addrspace(1)* %valptr, i32 %tid
|
|
|
|
%val = load <4 x i32>, <4 x i32> addrspace(1)* %in.gep, align 16
|
2014-06-17 19:36:24 +02:00
|
|
|
%ctlz = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> %val, i1 true) nounwind readnone
|
|
|
|
store <4 x i32> %ctlz, <4 x i32> addrspace(1)* %out, align 16
|
|
|
|
ret void
|
|
|
|
}
|
2016-01-11 17:50:29 +01:00
|
|
|
|
2016-01-11 18:02:06 +01:00
|
|
|
; FUNC-LABEL: {{^}}v_ctlz_zero_undef_i8:
|
2017-07-04 19:32:00 +02:00
|
|
|
; GCN: {{buffer|flat}}_load_ubyte [[VAL:v[0-9]+]],
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN: v_ffbh_u32_e32 [[RESULT:v[0-9]+]], [[VAL]]
|
|
|
|
; GCN: buffer_store_byte [[RESULT]],
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @v_ctlz_zero_undef_i8(i8 addrspace(1)* noalias %out, i8 addrspace(1)* noalias %valptr) nounwind {
|
2020-02-09 22:38:56 +01:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
2017-07-04 19:32:00 +02:00
|
|
|
%in.gep = getelementptr i8, i8 addrspace(1)* %valptr, i32 %tid
|
|
|
|
%val = load i8, i8 addrspace(1)* %in.gep
|
2016-01-11 18:02:06 +01:00
|
|
|
%ctlz = call i8 @llvm.ctlz.i8(i8 %val, i1 true) nounwind readnone
|
|
|
|
store i8 %ctlz, i8 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-01-11 17:50:29 +01:00
|
|
|
; FUNC-LABEL: {{^}}s_ctlz_zero_undef_i64:
|
AMDGPU: Add pass to lower kernel arguments to loads
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
2018-06-26 21:10:00 +02:00
|
|
|
; GCN: s_load_dwordx2 s{{\[}}[[LO:[0-9]+]]:[[HI:[0-9]+]]{{\]}}, s{{\[[0-9]+:[0-9]+\]}}, {{0x13|0x4c}}
|
2020-07-30 13:56:06 +02:00
|
|
|
; SI-DAG: v_cmp_eq_u32_e64 vcc, s[[HI]], 0{{$}}
|
|
|
|
; VI-DAG: s_cmp_eq_u32 s[[HI]], 0{{$}}
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN-DAG: s_flbit_i32_b32 [[FFBH_LO:s[0-9]+]], s[[LO]]
|
|
|
|
; GCN-DAG: s_add_i32 [[ADD:s[0-9]+]], [[FFBH_LO]], 32
|
|
|
|
; GCN-DAG: s_flbit_i32_b32 [[FFBH_HI:s[0-9]+]], s[[HI]]
|
2020-07-30 13:56:06 +02:00
|
|
|
; SI-DAG: v_mov_b32_e32 [[VFFBH_LO:v[0-9]+]], [[ADD]]
|
|
|
|
; SI-DAG: v_mov_b32_e32 [[VFFBH_HI:v[0-9]+]], [[FFBH_HI]]
|
|
|
|
; SI-DAG: v_cndmask_b32_e32 v[[CTLZ:[0-9]+]], [[VFFBH_HI]], [[VFFBH_LO]]
|
|
|
|
; VI-DAG: s_cselect_b32 [[RES:s[0-9]+]], [[ADD]], [[FFBH_HI]]
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN-DAG: v_mov_b32_e32 v[[CTLZ_HI:[0-9]+]], 0{{$}}
|
2020-07-30 13:56:06 +02:00
|
|
|
; VI-DAG: v_mov_b32_e32 v[[CTLZ:[0-9]+]], [[RES]]
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN: {{buffer|flat}}_store_dwordx2 v{{\[}}[[CTLZ]]:[[CTLZ_HI]]{{\]}}
|
AMDGPU: Add pass to lower kernel arguments to loads
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
2018-06-26 21:10:00 +02:00
|
|
|
define amdgpu_kernel void @s_ctlz_zero_undef_i64(i64 addrspace(1)* noalias %out, [8 x i32], i64 %val) nounwind {
|
2016-01-11 17:50:29 +01:00
|
|
|
%ctlz = call i64 @llvm.ctlz.i64(i64 %val, i1 true)
|
|
|
|
store i64 %ctlz, i64 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}s_ctlz_zero_undef_i64_trunc:
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @s_ctlz_zero_undef_i64_trunc(i32 addrspace(1)* noalias %out, i64 %val) nounwind {
|
2016-01-11 17:50:29 +01:00
|
|
|
%ctlz = call i64 @llvm.ctlz.i64(i64 %val, i1 true)
|
|
|
|
%trunc = trunc i64 %ctlz to i32
|
|
|
|
store i32 %trunc, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}v_ctlz_zero_undef_i64:
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN-DAG: {{buffer|flat}}_load_dwordx2 v{{\[}}[[LO:[0-9]+]]:[[HI:[0-9]+]]{{\]}}
|
2017-07-06 22:57:05 +02:00
|
|
|
; GCN-DAG: v_cmp_eq_u32_e32 vcc, 0, v[[HI]]
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN-DAG: v_ffbh_u32_e32 [[FFBH_LO:v[0-9]+]], v[[LO]]
|
2017-11-20 19:24:21 +01:00
|
|
|
; GCN-DAG: v_add_{{[iu]}}32_e32 [[ADD:v[0-9]+]], vcc, 32, [[FFBH_LO]]
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN-DAG: v_ffbh_u32_e32 [[FFBH_HI:v[0-9]+]], v[[HI]]
|
2017-07-06 22:57:05 +02:00
|
|
|
; GCN-DAG: v_cndmask_b32_e32 v[[CTLZ:[0-9]+]], [[FFBH_HI]], [[FFBH_LO]]
|
2017-05-22 18:58:10 +02:00
|
|
|
; GCN: {{buffer|flat}}_store_dwordx2 {{.*}}v{{\[}}[[CTLZ]]:[[CTLZ_HI:[0-9]+]]{{\]}}
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @v_ctlz_zero_undef_i64(i64 addrspace(1)* noalias %out, i64 addrspace(1)* noalias %in) nounwind {
|
2020-02-09 22:38:56 +01:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
2016-01-11 17:50:29 +01:00
|
|
|
%in.gep = getelementptr i64, i64 addrspace(1)* %in, i32 %tid
|
|
|
|
%out.gep = getelementptr i64, i64 addrspace(1)* %out, i32 %tid
|
|
|
|
%val = load i64, i64 addrspace(1)* %in.gep
|
|
|
|
%ctlz = call i64 @llvm.ctlz.i64(i64 %val, i1 true)
|
|
|
|
store i64 %ctlz, i64 addrspace(1)* %out.gep
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}v_ctlz_zero_undef_i64_trunc:
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @v_ctlz_zero_undef_i64_trunc(i32 addrspace(1)* noalias %out, i64 addrspace(1)* noalias %in) nounwind {
|
2020-02-09 22:38:56 +01:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
2016-01-11 17:50:29 +01:00
|
|
|
%in.gep = getelementptr i64, i64 addrspace(1)* %in, i32 %tid
|
|
|
|
%out.gep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
|
|
|
|
%val = load i64, i64 addrspace(1)* %in.gep
|
|
|
|
%ctlz = call i64 @llvm.ctlz.i64(i64 %val, i1 true)
|
|
|
|
%trunc = trunc i64 %ctlz to i32
|
|
|
|
store i32 %trunc, i32 addrspace(1)* %out.gep
|
|
|
|
ret void
|
|
|
|
}
|
2016-01-11 18:02:00 +01:00
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}v_ctlz_zero_undef_i32_sel_eq_neg1:
|
2017-07-04 19:32:00 +02:00
|
|
|
; GCN: {{buffer|flat}}_load_dword [[VAL:v[0-9]+]],
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN: v_ffbh_u32_e32 [[RESULT:v[0-9]+]], [[VAL]]
|
|
|
|
; GCN: buffer_store_dword [[RESULT]],
|
2017-07-04 19:32:00 +02:00
|
|
|
define amdgpu_kernel void @v_ctlz_zero_undef_i32_sel_eq_neg1(i32 addrspace(1)* noalias %out, i32 addrspace(1)* noalias %valptr) nounwind {
|
2020-02-09 22:38:56 +01:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
2017-07-04 19:32:00 +02:00
|
|
|
%in.gep = getelementptr i32, i32 addrspace(1)* %valptr, i32 %tid
|
|
|
|
%val = load i32, i32 addrspace(1)* %in.gep
|
2016-01-11 18:02:00 +01:00
|
|
|
%ctlz = call i32 @llvm.ctlz.i32(i32 %val, i1 true) nounwind readnone
|
|
|
|
%cmp = icmp eq i32 %val, 0
|
|
|
|
%sel = select i1 %cmp, i32 -1, i32 %ctlz
|
|
|
|
store i32 %sel, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}v_ctlz_zero_undef_i32_sel_ne_neg1:
|
2017-07-04 19:32:00 +02:00
|
|
|
; GCN: {{buffer|flat}}_load_dword [[VAL:v[0-9]+]],
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN: v_ffbh_u32_e32 [[RESULT:v[0-9]+]], [[VAL]]
|
|
|
|
; GCN: buffer_store_dword [[RESULT]],
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @v_ctlz_zero_undef_i32_sel_ne_neg1(i32 addrspace(1)* noalias %out, i32 addrspace(1)* noalias %valptr) nounwind {
|
2020-02-09 22:38:56 +01:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
2017-07-04 19:32:00 +02:00
|
|
|
%in.gep = getelementptr i32, i32 addrspace(1)* %valptr, i32 %tid
|
|
|
|
%val = load i32, i32 addrspace(1)* %in.gep
|
2016-01-11 18:02:00 +01:00
|
|
|
%ctlz = call i32 @llvm.ctlz.i32(i32 %val, i1 true) nounwind readnone
|
|
|
|
%cmp = icmp ne i32 %val, 0
|
|
|
|
%sel = select i1 %cmp, i32 %ctlz, i32 -1
|
|
|
|
store i32 %sel, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-01-11 18:02:06 +01:00
|
|
|
; FUNC-LABEL: {{^}}v_ctlz_zero_undef_i8_sel_eq_neg1:
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN: {{buffer|flat}}_load_ubyte [[VAL:v[0-9]+]],
|
|
|
|
; GCN: v_ffbh_u32_e32 [[FFBH:v[0-9]+]], [[VAL]]
|
|
|
|
; GCN: {{buffer|flat}}_store_byte [[FFBH]],
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @v_ctlz_zero_undef_i8_sel_eq_neg1(i8 addrspace(1)* noalias %out, i8 addrspace(1)* noalias %valptr) nounwind {
|
2020-02-09 22:38:56 +01:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
2016-10-07 16:22:58 +02:00
|
|
|
%valptr.gep = getelementptr i8, i8 addrspace(1)* %valptr, i32 %tid
|
|
|
|
%val = load i8, i8 addrspace(1)* %valptr.gep
|
2016-01-11 18:02:06 +01:00
|
|
|
%ctlz = call i8 @llvm.ctlz.i8(i8 %val, i1 true) nounwind readnone
|
|
|
|
%cmp = icmp eq i8 %val, 0
|
|
|
|
%sel = select i1 %cmp, i8 -1, i8 %ctlz
|
|
|
|
store i8 %sel, i8 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-01-11 18:02:00 +01:00
|
|
|
; FUNC-LABEL: {{^}}v_ctlz_zero_undef_i32_sel_eq_neg1_two_use:
|
2017-07-04 19:32:00 +02:00
|
|
|
; GCN: {{buffer|flat}}_load_dword [[VAL:v[0-9]+]],
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN-DAG: v_ffbh_u32_e32 [[RESULT0:v[0-9]+]], [[VAL]]
|
|
|
|
; GCN-DAG: v_cmp_eq_u32_e32 vcc, 0, [[VAL]]
|
|
|
|
; GCN-DAG: v_cndmask_b32_e64 [[RESULT1:v[0-9]+]], 0, 1, vcc
|
|
|
|
; GCN-DAG: buffer_store_dword [[RESULT0]]
|
|
|
|
; GCN-DAG: buffer_store_byte [[RESULT1]]
|
|
|
|
; GCN: s_endpgm
|
2017-07-04 19:32:00 +02:00
|
|
|
define amdgpu_kernel void @v_ctlz_zero_undef_i32_sel_eq_neg1_two_use(i32 addrspace(1)* noalias %out, i32 addrspace(1)* noalias %valptr) nounwind {
|
2020-02-09 22:38:56 +01:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
2017-07-04 19:32:00 +02:00
|
|
|
%in.gep = getelementptr i32, i32 addrspace(1)* %valptr, i32 %tid
|
|
|
|
%val = load i32, i32 addrspace(1)* %in.gep
|
2016-01-11 18:02:00 +01:00
|
|
|
%ctlz = call i32 @llvm.ctlz.i32(i32 %val, i1 true) nounwind readnone
|
|
|
|
%cmp = icmp eq i32 %val, 0
|
|
|
|
%sel = select i1 %cmp, i32 -1, i32 %ctlz
|
|
|
|
store volatile i32 %sel, i32 addrspace(1)* %out
|
|
|
|
store volatile i1 %cmp, i1 addrspace(1)* undef
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Selected on wrong constant
|
|
|
|
; FUNC-LABEL: {{^}}v_ctlz_zero_undef_i32_sel_eq_0:
|
2017-07-04 19:32:00 +02:00
|
|
|
; GCN: {{buffer|flat}}_load_dword
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN: v_ffbh_u32_e32
|
|
|
|
; GCN: v_cmp
|
|
|
|
; GCN: v_cndmask
|
|
|
|
; GCN: buffer_store_dword
|
2017-07-04 19:32:00 +02:00
|
|
|
define amdgpu_kernel void @v_ctlz_zero_undef_i32_sel_eq_0(i32 addrspace(1)* noalias %out, i32 addrspace(1)* noalias %valptr) nounwind {
|
2020-02-09 22:38:56 +01:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
2017-07-04 19:32:00 +02:00
|
|
|
%in.gep = getelementptr i32, i32 addrspace(1)* %valptr, i32 %tid
|
|
|
|
%val = load i32, i32 addrspace(1)* %in.gep
|
2016-01-11 18:02:00 +01:00
|
|
|
%ctlz = call i32 @llvm.ctlz.i32(i32 %val, i1 true) nounwind readnone
|
|
|
|
%cmp = icmp eq i32 %val, 0
|
|
|
|
%sel = select i1 %cmp, i32 0, i32 %ctlz
|
|
|
|
store i32 %sel, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Selected on wrong constant
|
|
|
|
; FUNC-LABEL: {{^}}v_ctlz_zero_undef_i32_sel_ne_0:
|
2017-07-04 19:32:00 +02:00
|
|
|
; GCN: {{buffer|flat}}_load_dword
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN: v_ffbh_u32_e32
|
|
|
|
; GCN: v_cmp
|
|
|
|
; GCN: v_cndmask
|
|
|
|
; GCN: buffer_store_dword
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @v_ctlz_zero_undef_i32_sel_ne_0(i32 addrspace(1)* noalias %out, i32 addrspace(1)* noalias %valptr) nounwind {
|
2020-02-09 22:38:56 +01:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
2017-07-04 19:32:00 +02:00
|
|
|
%in.gep = getelementptr i32, i32 addrspace(1)* %valptr, i32 %tid
|
|
|
|
%val = load i32, i32 addrspace(1)* %in.gep
|
2016-01-11 18:02:00 +01:00
|
|
|
%ctlz = call i32 @llvm.ctlz.i32(i32 %val, i1 true) nounwind readnone
|
|
|
|
%cmp = icmp ne i32 %val, 0
|
|
|
|
%sel = select i1 %cmp, i32 %ctlz, i32 0
|
|
|
|
store i32 %sel, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Compare on wrong constant
|
|
|
|
; FUNC-LABEL: {{^}}v_ctlz_zero_undef_i32_sel_eq_cmp_non0:
|
2017-07-04 19:32:00 +02:00
|
|
|
; GCN: {{buffer|flat}}_load_dword
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN: v_ffbh_u32_e32
|
|
|
|
; GCN: v_cmp
|
|
|
|
; GCN: v_cndmask
|
|
|
|
; GCN: buffer_store_dword
|
2017-07-04 19:32:00 +02:00
|
|
|
define amdgpu_kernel void @v_ctlz_zero_undef_i32_sel_eq_cmp_non0(i32 addrspace(1)* noalias %out, i32 addrspace(1)* noalias %valptr) nounwind {
|
2020-02-09 22:38:56 +01:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
2017-07-04 19:32:00 +02:00
|
|
|
%in.gep = getelementptr i32, i32 addrspace(1)* %valptr, i32 %tid
|
|
|
|
%val = load i32, i32 addrspace(1)* %in.gep
|
2016-01-11 18:02:00 +01:00
|
|
|
%ctlz = call i32 @llvm.ctlz.i32(i32 %val, i1 true) nounwind readnone
|
|
|
|
%cmp = icmp eq i32 %val, 1
|
|
|
|
%sel = select i1 %cmp, i32 0, i32 %ctlz
|
|
|
|
store i32 %sel, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Selected on wrong constant
|
|
|
|
; FUNC-LABEL: {{^}}v_ctlz_zero_undef_i32_sel_ne_cmp_non0:
|
2017-07-04 19:32:00 +02:00
|
|
|
; GCN: {{buffer|flat}}_load_dword
|
2016-11-01 18:49:33 +01:00
|
|
|
; GCN: v_ffbh_u32_e32
|
|
|
|
; GCN: v_cmp
|
|
|
|
; GCN: v_cndmask
|
|
|
|
; GCN: buffer_store_dword
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @v_ctlz_zero_undef_i32_sel_ne_cmp_non0(i32 addrspace(1)* noalias %out, i32 addrspace(1)* noalias %valptr) nounwind {
|
2020-02-09 22:38:56 +01:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
2017-07-04 19:32:00 +02:00
|
|
|
%in.gep = getelementptr i32, i32 addrspace(1)* %valptr, i32 %tid
|
|
|
|
%val = load i32, i32 addrspace(1)* %in.gep
|
2016-01-11 18:02:00 +01:00
|
|
|
%ctlz = call i32 @llvm.ctlz.i32(i32 %val, i1 true) nounwind readnone
|
|
|
|
%cmp = icmp ne i32 %val, 1
|
|
|
|
%sel = select i1 %cmp, i32 %ctlz, i32 0
|
|
|
|
store i32 %sel, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|