2017-08-07 22:58:04 +08:00
|
|
|
; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=GCN -check-prefix=FUNC %s
|
2017-01-25 06:02:15 +08:00
|
|
|
; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefix=VI -check-prefix=GCN -check-prefix=FUNC %s
|
2014-06-11 03:18:24 +08:00
|
|
|
|
2017-07-05 01:32:00 +08:00
|
|
|
declare i32 @llvm.r600.read.tidig.x() nounwind readnone
|
|
|
|
|
2014-06-11 03:18:24 +08:00
|
|
|
declare i64 @llvm.ctpop.i64(i64) nounwind readnone
|
|
|
|
declare <2 x i64> @llvm.ctpop.v2i64(<2 x i64>) nounwind readnone
|
|
|
|
declare <4 x i64> @llvm.ctpop.v4i64(<4 x i64>) nounwind readnone
|
|
|
|
declare <8 x i64> @llvm.ctpop.v8i64(<8 x i64>) nounwind readnone
|
|
|
|
declare <16 x i64> @llvm.ctpop.v16i64(<16 x i64>) nounwind readnone
|
|
|
|
|
2016-05-19 00:10:19 +08:00
|
|
|
declare i65 @llvm.ctpop.i65(i65) nounwind readnone
|
|
|
|
declare i128 @llvm.ctpop.i128(i128) nounwind readnone
|
|
|
|
|
2014-10-02 01:15:17 +08:00
|
|
|
; FUNC-LABEL: {{^}}s_ctpop_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-27 03:10:00 +08:00
|
|
|
; SI: s_load_dwordx2 [[SVAL:s\[[0-9]+:[0-9]+\]]], s{{\[[0-9]+:[0-9]+\]}}, 0x13
|
|
|
|
; VI: s_load_dwordx2 [[SVAL:s\[[0-9]+:[0-9]+\]]], s{{\[[0-9]+:[0-9]+\]}}, 0x4c
|
2015-02-11 22:26:46 +08:00
|
|
|
; GCN: s_bcnt1_i32_b64 [[SRESULT:s[0-9]+]], [[SVAL]]
|
|
|
|
; GCN: v_mov_b32_e32 [[VRESULT:v[0-9]+]], [[SRESULT]]
|
|
|
|
; GCN: buffer_store_dword [[VRESULT]],
|
|
|
|
; GCN: s_endpgm
|
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-27 03:10:00 +08:00
|
|
|
define amdgpu_kernel void @s_ctpop_i64(i32 addrspace(1)* noalias %out, [8 x i32], i64 %val) nounwind {
|
2014-06-11 03:18:24 +08:00
|
|
|
%ctpop = call i64 @llvm.ctpop.i64(i64 %val) nounwind readnone
|
|
|
|
%truncctpop = trunc i64 %ctpop to i32
|
|
|
|
store i32 %truncctpop, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-02 01:15:17 +08:00
|
|
|
; FUNC-LABEL: {{^}}v_ctpop_i64:
|
2017-07-05 01:32:00 +08:00
|
|
|
; GCN: {{buffer|flat}}_load_dwordx2 v{{\[}}[[LOVAL:[0-9]+]]:[[HIVAL:[0-9]+]]{{\]}},
|
2017-05-15 22:28:23 +08:00
|
|
|
; GCN: v_bcnt_u32_b32{{(_e64)*}} [[MIDRESULT:v[0-9]+]], v[[LOVAL]], 0
|
2014-11-05 22:50:53 +08:00
|
|
|
; SI-NEXT: v_bcnt_u32_b32_e32 [[RESULT:v[0-9]+]], v[[HIVAL]], [[MIDRESULT]]
|
2017-05-15 22:28:23 +08:00
|
|
|
; VI-NEXT: v_bcnt_u32_b32 [[RESULT:v[0-9]+]], v[[HIVAL]], [[MIDRESULT]]
|
2015-02-11 22:26:46 +08:00
|
|
|
; GCN: buffer_store_dword [[RESULT]],
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @v_ctpop_i64(i32 addrspace(1)* noalias %out, i64 addrspace(1)* noalias %in) nounwind {
|
2017-07-05 01:32:00 +08:00
|
|
|
%tid = call i32 @llvm.r600.read.tidig.x()
|
|
|
|
%in.gep = getelementptr i64, i64 addrspace(1)* %in, i32 %tid
|
|
|
|
%val = load i64, i64 addrspace(1)* %in.gep, align 8
|
2014-06-11 03:18:24 +08:00
|
|
|
%ctpop = call i64 @llvm.ctpop.i64(i64 %val) nounwind readnone
|
|
|
|
%truncctpop = trunc i64 %ctpop to i32
|
|
|
|
store i32 %truncctpop, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2015-08-27 04:48:04 +08:00
|
|
|
; FUNC-LABEL: {{^}}v_ctpop_i64_user:
|
2017-07-05 01:32:00 +08:00
|
|
|
; GCN: {{buffer|flat}}_load_dwordx2 v{{\[}}[[LOVAL:[0-9]+]]:[[HIVAL:[0-9]+]]{{\]}},
|
2017-05-15 22:28:23 +08:00
|
|
|
; GCN: v_bcnt_u32_b32{{(_e64)*}} [[MIDRESULT:v[0-9]+]], v[[LOVAL]], 0
|
2015-08-27 04:48:04 +08:00
|
|
|
; SI-NEXT: v_bcnt_u32_b32_e32 [[RESULT:v[0-9]+]], v[[HIVAL]], [[MIDRESULT]]
|
2017-05-15 22:28:23 +08:00
|
|
|
; VI-NEXT: v_bcnt_u32_b32 [[RESULT:v[0-9]+]], v[[HIVAL]], [[MIDRESULT]]
|
2015-08-27 04:48:04 +08:00
|
|
|
; GCN-DAG: v_or_b32_e32 v[[RESULT_LO:[0-9]+]], s{{[0-9]+}}, [[RESULT]]
|
2016-09-14 23:19:03 +08:00
|
|
|
; GCN-DAG: v_mov_b32_e32 v[[RESULT_HI:[0-9]+]], s{{[0-9]+}}
|
2015-08-27 04:48:04 +08:00
|
|
|
; GCN: buffer_store_dwordx2 v{{\[}}[[RESULT_LO]]:[[RESULT_HI]]{{\]}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @v_ctpop_i64_user(i64 addrspace(1)* noalias %out, i64 addrspace(1)* noalias %in, i64 %s.val) nounwind {
|
2017-07-05 01:32:00 +08:00
|
|
|
%tid = call i32 @llvm.r600.read.tidig.x()
|
|
|
|
%in.gep = getelementptr i64, i64 addrspace(1)* %in, i32 %tid
|
|
|
|
%val = load i64, i64 addrspace(1)* %in.gep, align 8
|
2015-08-27 04:48:04 +08:00
|
|
|
%ctpop = call i64 @llvm.ctpop.i64(i64 %val) nounwind readnone
|
|
|
|
%or = or i64 %ctpop, %s.val
|
|
|
|
store i64 %or, i64 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-02 01:15:17 +08:00
|
|
|
; FUNC-LABEL: {{^}}s_ctpop_v2i64:
|
2015-02-11 22:26:46 +08:00
|
|
|
; GCN: s_bcnt1_i32_b64
|
|
|
|
; GCN: s_bcnt1_i32_b64
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @s_ctpop_v2i64(<2 x i32> addrspace(1)* noalias %out, <2 x i64> %val) nounwind {
|
2014-06-11 03:18:24 +08:00
|
|
|
%ctpop = call <2 x i64> @llvm.ctpop.v2i64(<2 x i64> %val) nounwind readnone
|
|
|
|
%truncctpop = trunc <2 x i64> %ctpop to <2 x i32>
|
|
|
|
store <2 x i32> %truncctpop, <2 x i32> addrspace(1)* %out, align 8
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-02 01:15:17 +08:00
|
|
|
; FUNC-LABEL: {{^}}s_ctpop_v4i64:
|
2015-02-11 22:26:46 +08:00
|
|
|
; GCN: s_bcnt1_i32_b64
|
|
|
|
; GCN: s_bcnt1_i32_b64
|
|
|
|
; GCN: s_bcnt1_i32_b64
|
|
|
|
; GCN: s_bcnt1_i32_b64
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @s_ctpop_v4i64(<4 x i32> addrspace(1)* noalias %out, <4 x i64> %val) nounwind {
|
2014-06-11 03:18:24 +08:00
|
|
|
%ctpop = call <4 x i64> @llvm.ctpop.v4i64(<4 x i64> %val) nounwind readnone
|
|
|
|
%truncctpop = trunc <4 x i64> %ctpop to <4 x i32>
|
|
|
|
store <4 x i32> %truncctpop, <4 x i32> addrspace(1)* %out, align 16
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-02 01:15:17 +08:00
|
|
|
; FUNC-LABEL: {{^}}v_ctpop_v2i64:
|
2015-02-11 22:26:46 +08:00
|
|
|
; GCN: v_bcnt_u32_b32
|
|
|
|
; GCN: v_bcnt_u32_b32
|
|
|
|
; GCN: v_bcnt_u32_b32
|
|
|
|
; GCN: v_bcnt_u32_b32
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @v_ctpop_v2i64(<2 x i32> addrspace(1)* noalias %out, <2 x i64> addrspace(1)* noalias %in) nounwind {
|
2017-07-05 01:32:00 +08:00
|
|
|
%tid = call i32 @llvm.r600.read.tidig.x()
|
|
|
|
%in.gep = getelementptr <2 x i64>, <2 x i64> addrspace(1)* %in, i32 %tid
|
|
|
|
%val = load <2 x i64>, <2 x i64> addrspace(1)* %in.gep, align 16
|
2014-06-11 03:18:24 +08:00
|
|
|
%ctpop = call <2 x i64> @llvm.ctpop.v2i64(<2 x i64> %val) nounwind readnone
|
|
|
|
%truncctpop = trunc <2 x i64> %ctpop to <2 x i32>
|
|
|
|
store <2 x i32> %truncctpop, <2 x i32> addrspace(1)* %out, align 8
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-02 01:15:17 +08:00
|
|
|
; FUNC-LABEL: {{^}}v_ctpop_v4i64:
|
2015-02-11 22:26:46 +08:00
|
|
|
; GCN: v_bcnt_u32_b32
|
|
|
|
; GCN: v_bcnt_u32_b32
|
|
|
|
; GCN: v_bcnt_u32_b32
|
|
|
|
; GCN: v_bcnt_u32_b32
|
|
|
|
; GCN: v_bcnt_u32_b32
|
|
|
|
; GCN: v_bcnt_u32_b32
|
|
|
|
; GCN: v_bcnt_u32_b32
|
|
|
|
; GCN: v_bcnt_u32_b32
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @v_ctpop_v4i64(<4 x i32> addrspace(1)* noalias %out, <4 x i64> addrspace(1)* noalias %in) nounwind {
|
2017-07-05 01:32:00 +08:00
|
|
|
%tid = call i32 @llvm.r600.read.tidig.x()
|
|
|
|
%in.gep = getelementptr <4 x i64>, <4 x i64> addrspace(1)* %in, i32 %tid
|
|
|
|
%val = load <4 x i64>, <4 x i64> addrspace(1)* %in.gep, align 32
|
2014-06-11 03:18:24 +08:00
|
|
|
%ctpop = call <4 x i64> @llvm.ctpop.v4i64(<4 x i64> %val) nounwind readnone
|
|
|
|
%truncctpop = trunc <4 x i64> %ctpop to <4 x i32>
|
|
|
|
store <4 x i32> %truncctpop, <4 x i32> addrspace(1)* %out, align 16
|
|
|
|
ret void
|
|
|
|
}
|
2014-06-21 01:06:11 +08:00
|
|
|
|
2014-10-02 01:15:17 +08:00
|
|
|
; FUNC-LABEL: {{^}}ctpop_i64_in_br:
|
2016-05-21 08:29:27 +08:00
|
|
|
; SI-DAG: s_load_dwordx2 s{{\[}}[[LOVAL:[0-9]+]]:[[HIVAL:[0-9]+]]{{\]}}, s[{{[0-9]+:[0-9]+}}], 0xd
|
|
|
|
; VI-DAG: s_load_dwordx2 s{{\[}}[[LOVAL:[0-9]+]]:[[HIVAL:[0-9]+]]{{\]}}, s[{{[0-9]+:[0-9]+}}], 0x34
|
2016-03-31 00:35:09 +08:00
|
|
|
; GCN-DAG: s_bcnt1_i32_b64 [[RESULT:s[0-9]+]], {{s\[}}[[LOVAL]]:[[HIVAL]]{{\]}}
|
|
|
|
; GCN-DAG: s_mov_b32 [[ZERO:s[0-9]+]], 0
|
2015-12-19 09:16:06 +08:00
|
|
|
; GCN-DAG: v_mov_b32_e32 v[[VLO:[0-9]+]], [[RESULT]]
|
2016-03-31 00:35:09 +08:00
|
|
|
; GCN-DAG: v_mov_b32_e32 v[[VHI:[0-9]+]], [[ZERO]]
|
2015-02-11 22:26:46 +08:00
|
|
|
; GCN: buffer_store_dwordx2 {{v\[}}[[VLO]]:[[VHI]]{{\]}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @ctpop_i64_in_br(i64 addrspace(1)* %out, i64 addrspace(1)* %in, i64 %ctpop_arg, i32 %cond) {
|
2014-06-21 01:06:11 +08:00
|
|
|
entry:
|
2014-09-24 09:33:28 +08:00
|
|
|
%tmp0 = icmp eq i32 %cond, 0
|
|
|
|
br i1 %tmp0, label %if, label %else
|
2014-06-21 01:06:11 +08:00
|
|
|
|
|
|
|
if:
|
2014-09-24 09:33:28 +08:00
|
|
|
%tmp2 = call i64 @llvm.ctpop.i64(i64 %ctpop_arg)
|
2014-06-21 01:06:11 +08:00
|
|
|
br label %endif
|
|
|
|
|
|
|
|
else:
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
llvm-svn: 230786
2015-02-28 03:29:02 +08:00
|
|
|
%tmp3 = getelementptr i64, i64 addrspace(1)* %in, i32 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp4 = load i64, i64 addrspace(1)* %tmp3
|
2014-06-21 01:06:11 +08:00
|
|
|
br label %endif
|
|
|
|
|
|
|
|
endif:
|
2014-09-24 09:33:28 +08:00
|
|
|
%tmp5 = phi i64 [%tmp2, %if], [%tmp4, %else]
|
|
|
|
store i64 %tmp5, i64 addrspace(1)* %out
|
2014-06-21 01:06:11 +08:00
|
|
|
ret void
|
|
|
|
}
|
2016-05-19 00:10:19 +08:00
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}s_ctpop_i128:
|
|
|
|
; GCN: s_bcnt1_i32_b64 [[SRESULT0:s[0-9]+]],
|
|
|
|
; GCN: s_bcnt1_i32_b64 [[SRESULT1:s[0-9]+]],
|
2016-06-25 07:52:11 +08:00
|
|
|
; GCN: s_add_i32 s{{[0-9]+}}, [[SRESULT1]], [[SRESULT0]]
|
2016-05-19 00:10:19 +08:00
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @s_ctpop_i128(i32 addrspace(1)* noalias %out, i128 %val) nounwind {
|
2016-05-19 00:10:19 +08:00
|
|
|
%ctpop = call i128 @llvm.ctpop.i128(i128 %val) nounwind readnone
|
|
|
|
%truncctpop = trunc i128 %ctpop to i32
|
|
|
|
store i32 %truncctpop, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}s_ctpop_i65:
|
2016-06-25 08:23:00 +08:00
|
|
|
; GCN: s_bcnt1_i32_b64 [[REG0:s[0-9]+]],
|
2016-08-30 03:42:52 +08:00
|
|
|
; GCN: s_and_b32
|
2016-06-25 08:23:00 +08:00
|
|
|
; GCN: s_bcnt1_i32_b64 [[REG1:s[0-9]+]],
|
|
|
|
; GCN: s_add_i32 {{s[0-9]+}}, [[REG0]], [[REG1]]
|
2016-05-19 00:10:19 +08:00
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @s_ctpop_i65(i32 addrspace(1)* noalias %out, i65 %val) nounwind {
|
2016-05-19 00:10:19 +08:00
|
|
|
%ctpop = call i65 @llvm.ctpop.i65(i65 %val) nounwind readnone
|
|
|
|
%truncctpop = trunc i65 %ctpop to i32
|
|
|
|
store i32 %truncctpop, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FIXME: Should not have extra add
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}v_ctpop_i128:
|
2017-07-05 01:32:00 +08:00
|
|
|
; SI: buffer_load_dwordx4 v{{\[}}[[VAL0:[0-9]+]]:[[VAL3:[0-9]+]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64
|
|
|
|
; VI: flat_load_dwordx4 v{{\[}}[[VAL0:[0-9]+]]:[[VAL3:[0-9]+]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}
|
2016-05-19 00:10:19 +08:00
|
|
|
|
2017-05-15 22:28:23 +08:00
|
|
|
; GCN-DAG: v_bcnt_u32_b32{{(_e64)*}} [[MIDRESULT0:v[0-9]+]], v{{[0-9]+}}, 0
|
|
|
|
; GCN-DAG: v_bcnt_u32_b32{{(_e32)*(_e64)*}} [[MIDRESULT1:v[0-9]+]], v[[VAL3]], [[MIDRESULT0]]
|
2016-05-19 00:10:19 +08:00
|
|
|
|
2017-05-15 22:28:23 +08:00
|
|
|
; GCN-DAG: v_bcnt_u32_b32{{(_e64)*}} [[MIDRESULT2:v[0-9]+]], v[[VAL0]], 0
|
|
|
|
; GCN-DAG: v_bcnt_u32_b32{{(_e32)*(_e64)*}} [[MIDRESULT3:v[0-9]+]], v{{[0-9]+}}, [[MIDRESULT2]]
|
2016-05-19 00:10:19 +08:00
|
|
|
|
2018-09-21 18:31:22 +08:00
|
|
|
; GCN: v_add_{{[iu]}}32_e32 [[RESULT:v[0-9]+]], vcc, [[MIDRESULT2]], [[MIDRESULT1]]
|
2016-05-19 00:10:19 +08:00
|
|
|
|
|
|
|
; GCN: buffer_store_dword [[RESULT]],
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @v_ctpop_i128(i32 addrspace(1)* noalias %out, i128 addrspace(1)* noalias %in) nounwind {
|
2017-07-05 01:32:00 +08:00
|
|
|
%tid = call i32 @llvm.r600.read.tidig.x()
|
|
|
|
%in.gep = getelementptr i128, i128 addrspace(1)* %in, i32 %tid
|
|
|
|
%val = load i128, i128 addrspace(1)* %in.gep, align 8
|
2016-05-19 00:10:19 +08:00
|
|
|
%ctpop = call i128 @llvm.ctpop.i128(i128 %val) nounwind readnone
|
|
|
|
%truncctpop = trunc i128 %ctpop to i32
|
|
|
|
store i32 %truncctpop, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|