2016-05-21 00:29:27 +00:00
|
|
|
; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=GCN -check-prefix=FUNC %s
|
2015-02-11 14:26:46 +00:00
|
|
|
; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=VI -check-prefix=GCN -check-prefix=FUNC %s
|
2014-06-10 19:18:24 +00: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-18 16:10:19 +00:00
|
|
|
declare i65 @llvm.ctpop.i65(i65) nounwind readnone
|
|
|
|
declare i128 @llvm.ctpop.i128(i128) nounwind readnone
|
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}s_ctpop_i64:
|
2014-11-05 14:50:53 +00:00
|
|
|
; SI: s_load_dwordx2 [[SVAL:s\[[0-9]+:[0-9]+\]]], s{{\[[0-9]+:[0-9]+\]}}, 0xb
|
2015-02-11 14:26:46 +00:00
|
|
|
; VI: s_load_dwordx2 [[SVAL:s\[[0-9]+:[0-9]+\]]], s{{\[[0-9]+:[0-9]+\]}}, 0x2c
|
|
|
|
; 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
|
2014-06-10 19:18:24 +00:00
|
|
|
define void @s_ctpop_i64(i32 addrspace(1)* noalias %out, i64 %val) nounwind {
|
|
|
|
%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-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}v_ctpop_i64:
|
2015-02-11 14:26:46 +00:00
|
|
|
; GCN: buffer_load_dwordx2 v{{\[}}[[LOVAL:[0-9]+]]:[[HIVAL:[0-9]+]]{{\]}},
|
|
|
|
; GCN: v_bcnt_u32_b32_e64 [[MIDRESULT:v[0-9]+]], v[[LOVAL]], 0
|
2014-11-05 14:50:53 +00:00
|
|
|
; SI-NEXT: v_bcnt_u32_b32_e32 [[RESULT:v[0-9]+]], v[[HIVAL]], [[MIDRESULT]]
|
2015-02-11 14:26:46 +00:00
|
|
|
; VI-NEXT: v_bcnt_u32_b32_e64 [[RESULT:v[0-9]+]], v[[HIVAL]], [[MIDRESULT]]
|
|
|
|
; GCN: buffer_store_dword [[RESULT]],
|
|
|
|
; GCN: s_endpgm
|
2014-06-10 19:18:24 +00:00
|
|
|
define void @v_ctpop_i64(i32 addrspace(1)* noalias %out, i64 addrspace(1)* noalias %in) nounwind {
|
2015-02-27 21:17:42 +00:00
|
|
|
%val = load i64, i64 addrspace(1)* %in, align 8
|
2014-06-10 19:18:24 +00: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-26 20:48:04 +00:00
|
|
|
; FUNC-LABEL: {{^}}v_ctpop_i64_user:
|
|
|
|
; GCN: buffer_load_dwordx2 v{{\[}}[[LOVAL:[0-9]+]]:[[HIVAL:[0-9]+]]{{\]}},
|
|
|
|
; GCN: v_bcnt_u32_b32_e64 [[MIDRESULT:v[0-9]+]], v[[LOVAL]], 0
|
|
|
|
; SI-NEXT: v_bcnt_u32_b32_e32 [[RESULT:v[0-9]+]], v[[HIVAL]], [[MIDRESULT]]
|
|
|
|
; VI-NEXT: v_bcnt_u32_b32_e64 [[RESULT:v[0-9]+]], v[[HIVAL]], [[MIDRESULT]]
|
|
|
|
; GCN-DAG: v_or_b32_e32 v[[RESULT_LO:[0-9]+]], s{{[0-9]+}}, [[RESULT]]
|
2016-09-14 15:19:03 +00:00
|
|
|
; GCN-DAG: v_mov_b32_e32 v[[RESULT_HI:[0-9]+]], s{{[0-9]+}}
|
2015-08-26 20:48:04 +00:00
|
|
|
; GCN: buffer_store_dwordx2 v{{\[}}[[RESULT_LO]]:[[RESULT_HI]]{{\]}}
|
|
|
|
; GCN: s_endpgm
|
|
|
|
define void @v_ctpop_i64_user(i64 addrspace(1)* noalias %out, i64 addrspace(1)* noalias %in, i64 %s.val) nounwind {
|
|
|
|
%val = load i64, i64 addrspace(1)* %in, align 8
|
|
|
|
%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-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}s_ctpop_v2i64:
|
2015-02-11 14:26:46 +00:00
|
|
|
; GCN: s_bcnt1_i32_b64
|
|
|
|
; GCN: s_bcnt1_i32_b64
|
|
|
|
; GCN: s_endpgm
|
2014-06-10 19:18:24 +00:00
|
|
|
define void @s_ctpop_v2i64(<2 x i32> addrspace(1)* noalias %out, <2 x i64> %val) nounwind {
|
|
|
|
%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-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}s_ctpop_v4i64:
|
2015-02-11 14:26:46 +00:00
|
|
|
; GCN: s_bcnt1_i32_b64
|
|
|
|
; GCN: s_bcnt1_i32_b64
|
|
|
|
; GCN: s_bcnt1_i32_b64
|
|
|
|
; GCN: s_bcnt1_i32_b64
|
|
|
|
; GCN: s_endpgm
|
2014-06-10 19:18:24 +00:00
|
|
|
define void @s_ctpop_v4i64(<4 x i32> addrspace(1)* noalias %out, <4 x i64> %val) nounwind {
|
|
|
|
%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-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}v_ctpop_v2i64:
|
2015-02-11 14:26:46 +00:00
|
|
|
; GCN: v_bcnt_u32_b32
|
|
|
|
; GCN: v_bcnt_u32_b32
|
|
|
|
; GCN: v_bcnt_u32_b32
|
|
|
|
; GCN: v_bcnt_u32_b32
|
|
|
|
; GCN: s_endpgm
|
2014-06-10 19:18:24 +00:00
|
|
|
define void @v_ctpop_v2i64(<2 x i32> addrspace(1)* noalias %out, <2 x i64> addrspace(1)* noalias %in) nounwind {
|
2015-02-27 21:17:42 +00:00
|
|
|
%val = load <2 x i64>, <2 x i64> addrspace(1)* %in, align 16
|
2014-06-10 19:18:24 +00: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-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}v_ctpop_v4i64:
|
2015-02-11 14:26:46 +00: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
|
2014-06-10 19:18:24 +00:00
|
|
|
define void @v_ctpop_v4i64(<4 x i32> addrspace(1)* noalias %out, <4 x i64> addrspace(1)* noalias %in) nounwind {
|
2015-02-27 21:17:42 +00:00
|
|
|
%val = load <4 x i64>, <4 x i64> addrspace(1)* %in, align 32
|
2014-06-10 19:18:24 +00: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-20 17:06:11 +00:00
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}ctpop_i64_in_br:
|
2016-05-21 00:29:27 +00: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-30 16:35:09 +00: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 01:16:06 +00:00
|
|
|
; GCN-DAG: v_mov_b32_e32 v[[VLO:[0-9]+]], [[RESULT]]
|
2016-03-30 16:35:09 +00:00
|
|
|
; GCN-DAG: v_mov_b32_e32 v[[VHI:[0-9]+]], [[ZERO]]
|
2015-02-11 14:26:46 +00:00
|
|
|
; GCN: buffer_store_dwordx2 {{v\[}}[[VLO]]:[[VHI]]{{\]}}
|
|
|
|
; GCN: s_endpgm
|
2014-09-24 01:33:28 +00:00
|
|
|
define void @ctpop_i64_in_br(i64 addrspace(1)* %out, i64 addrspace(1)* %in, i64 %ctpop_arg, i32 %cond) {
|
2014-06-20 17:06:11 +00:00
|
|
|
entry:
|
2014-09-24 01:33:28 +00:00
|
|
|
%tmp0 = icmp eq i32 %cond, 0
|
|
|
|
br i1 %tmp0, label %if, label %else
|
2014-06-20 17:06:11 +00:00
|
|
|
|
|
|
|
if:
|
2014-09-24 01:33:28 +00:00
|
|
|
%tmp2 = call i64 @llvm.ctpop.i64(i64 %ctpop_arg)
|
2014-06-20 17:06:11 +00: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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%tmp3 = getelementptr i64, i64 addrspace(1)* %in, i32 1
|
2015-02-27 21:17:42 +00:00
|
|
|
%tmp4 = load i64, i64 addrspace(1)* %tmp3
|
2014-06-20 17:06:11 +00:00
|
|
|
br label %endif
|
|
|
|
|
|
|
|
endif:
|
2014-09-24 01:33:28 +00:00
|
|
|
%tmp5 = phi i64 [%tmp2, %if], [%tmp4, %else]
|
|
|
|
store i64 %tmp5, i64 addrspace(1)* %out
|
2014-06-20 17:06:11 +00:00
|
|
|
ret void
|
|
|
|
}
|
2016-05-18 16:10:19 +00: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-24 23:52:11 +00:00
|
|
|
; GCN: s_add_i32 s{{[0-9]+}}, [[SRESULT1]], [[SRESULT0]]
|
2016-05-18 16:10:19 +00:00
|
|
|
; GCN: s_endpgm
|
|
|
|
define void @s_ctpop_i128(i32 addrspace(1)* noalias %out, i128 %val) nounwind {
|
|
|
|
%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 00:23:00 +00:00
|
|
|
; GCN: s_bcnt1_i32_b64 [[REG0:s[0-9]+]],
|
2016-08-29 19:42:52 +00:00
|
|
|
; GCN: s_and_b32
|
2016-06-25 00:23:00 +00:00
|
|
|
; GCN: s_bcnt1_i32_b64 [[REG1:s[0-9]+]],
|
|
|
|
; GCN: s_add_i32 {{s[0-9]+}}, [[REG0]], [[REG1]]
|
2016-05-18 16:10:19 +00:00
|
|
|
; GCN: s_endpgm
|
|
|
|
define void @s_ctpop_i65(i32 addrspace(1)* noalias %out, i65 %val) nounwind {
|
|
|
|
%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:
|
2016-07-01 22:47:50 +00:00
|
|
|
; GCN: buffer_load_dwordx4 v{{\[}}[[VAL0:[0-9]+]]:[[VAL3:[0-9]+]]{{\]}}, off, s{{\[[0-9]+:[0-9]+\]}}, 0{{$}}
|
2016-05-18 16:10:19 +00:00
|
|
|
|
2016-07-01 22:47:50 +00: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-18 16:10:19 +00:00
|
|
|
|
2016-07-01 22:47:50 +00: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-18 16:10:19 +00:00
|
|
|
|
2016-07-01 22:47:50 +00:00
|
|
|
; GCN: v_add_i32_e32 [[RESULT:v[0-9]+]], vcc, [[MIDRESULT1]], [[MIDRESULT2]]
|
2016-05-18 16:10:19 +00:00
|
|
|
|
|
|
|
; GCN: buffer_store_dword [[RESULT]],
|
|
|
|
; GCN: s_endpgm
|
|
|
|
define void @v_ctpop_i128(i32 addrspace(1)* noalias %out, i128 addrspace(1)* noalias %in) nounwind {
|
|
|
|
%val = load i128, i128 addrspace(1)* %in, align 8
|
|
|
|
%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
|
|
|
|
}
|