2016-05-21 09:53:33 +08:00
|
|
|
; RUN: llc -march=amdgcn < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
|
2015-01-28 01:27:15 +08:00
|
|
|
; RUN: llc -march=amdgcn -mcpu=tonga < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
|
2014-06-16 03:48:16 +08:00
|
|
|
; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
|
2012-12-12 05:25:42 +08:00
|
|
|
|
|
|
|
; The code generated by sdiv is long and complex and may frequently change.
|
|
|
|
; The goal of this test is to make sure the ISel doesn't fail.
|
|
|
|
;
|
|
|
|
; This program was previously failing to compile when one of the selectcc
|
|
|
|
; opcodes generated by the sdiv lowering was being legalized and optimized to:
|
|
|
|
; selectcc Remainder -1, 0, -1, SETGT
|
|
|
|
; This was fixed by adding an additional pattern in R600Instructions.td to
|
|
|
|
; match this pattern with a CNDGE_INT.
|
|
|
|
|
2014-10-02 01:15:17 +08:00
|
|
|
; FUNC-LABEL: {{^}}sdiv_i32:
|
2014-06-16 03:48:16 +08:00
|
|
|
; EG: CF_END
|
|
|
|
define void @sdiv_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
|
[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
|
|
|
%den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%num = load i32, i32 addrspace(1) * %in
|
|
|
|
%den = load i32, i32 addrspace(1) * %den_ptr
|
2012-12-12 05:25:42 +08:00
|
|
|
%result = sdiv i32 %num, %den
|
|
|
|
store i32 %result, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
2014-06-16 03:48:16 +08:00
|
|
|
|
2014-10-02 01:15:17 +08:00
|
|
|
; FUNC-LABEL: {{^}}sdiv_i32_4:
|
2014-06-16 03:48:16 +08:00
|
|
|
define void @sdiv_i32_4(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
|
2015-02-28 05:17:42 +08:00
|
|
|
%num = load i32, i32 addrspace(1) * %in
|
2014-06-16 03:48:16 +08:00
|
|
|
%result = sdiv i32 %num, 4
|
|
|
|
store i32 %result, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Multiply by a weird constant to make sure setIntDivIsCheap is
|
|
|
|
; working.
|
|
|
|
|
2014-10-02 01:15:17 +08:00
|
|
|
; FUNC-LABEL: {{^}}slow_sdiv_i32_3435:
|
2014-11-05 22:50:53 +08:00
|
|
|
; SI: buffer_load_dword [[VAL:v[0-9]+]],
|
|
|
|
; SI: v_mov_b32_e32 [[MAGIC:v[0-9]+]], 0x98a1930b
|
2015-01-08 06:44:19 +08:00
|
|
|
; SI: v_mul_hi_i32 [[TMP:v[0-9]+]], [[MAGIC]], [[VAL]]
|
2014-11-05 22:50:53 +08:00
|
|
|
; SI: v_add_i32
|
|
|
|
; SI: v_lshrrev_b32
|
|
|
|
; SI: v_ashrrev_i32
|
|
|
|
; SI: v_add_i32
|
|
|
|
; SI: buffer_store_dword
|
|
|
|
; SI: s_endpgm
|
2014-06-16 03:48:16 +08:00
|
|
|
define void @slow_sdiv_i32_3435(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
|
2015-02-28 05:17:42 +08:00
|
|
|
%num = load i32, i32 addrspace(1) * %in
|
2014-06-16 03:48:16 +08:00
|
|
|
%result = sdiv i32 %num, 3435
|
|
|
|
store i32 %result, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-06-16 05:08:54 +08:00
|
|
|
define void @sdiv_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> addrspace(1)* %in) {
|
[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
|
|
|
%den_ptr = getelementptr <2 x i32>, <2 x i32> addrspace(1)* %in, i32 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%num = load <2 x i32>, <2 x i32> addrspace(1) * %in
|
|
|
|
%den = load <2 x i32>, <2 x i32> addrspace(1) * %den_ptr
|
2014-06-16 05:08:54 +08:00
|
|
|
%result = sdiv <2 x i32> %num, %den
|
|
|
|
store <2 x i32> %result, <2 x i32> addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @sdiv_v2i32_4(<2 x i32> addrspace(1)* %out, <2 x i32> addrspace(1)* %in) {
|
2015-02-28 05:17:42 +08:00
|
|
|
%num = load <2 x i32>, <2 x i32> addrspace(1) * %in
|
2014-06-16 05:08:54 +08:00
|
|
|
%result = sdiv <2 x i32> %num, <i32 4, i32 4>
|
|
|
|
store <2 x i32> %result, <2 x i32> addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @sdiv_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %in) {
|
[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
|
|
|
%den_ptr = getelementptr <4 x i32>, <4 x i32> addrspace(1)* %in, i32 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%num = load <4 x i32>, <4 x i32> addrspace(1) * %in
|
|
|
|
%den = load <4 x i32>, <4 x i32> addrspace(1) * %den_ptr
|
2014-06-16 05:08:54 +08:00
|
|
|
%result = sdiv <4 x i32> %num, %den
|
|
|
|
store <4 x i32> %result, <4 x i32> addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @sdiv_v4i32_4(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %in) {
|
2015-02-28 05:17:42 +08:00
|
|
|
%num = load <4 x i32>, <4 x i32> addrspace(1) * %in
|
2014-06-16 05:08:54 +08:00
|
|
|
%result = sdiv <4 x i32> %num, <i32 4, i32 4, i32 4, i32 4>
|
|
|
|
store <4 x i32> %result, <4 x i32> addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-05-21 09:53:33 +08:00
|
|
|
; FUNC-LABEL: {{^}}v_sdiv_i8:
|
|
|
|
; SI: v_rcp_f32
|
|
|
|
; SI: v_bfe_i32 [[BFE:v[0-9]+]], v{{[0-9]+}}, 0, 8
|
|
|
|
; SI: buffer_store_dword [[BFE]]
|
|
|
|
define void @v_sdiv_i8(i32 addrspace(1)* %out, i8 addrspace(1)* %in) {
|
|
|
|
%den_ptr = getelementptr i8, i8 addrspace(1)* %in, i8 1
|
|
|
|
%num = load i8, i8 addrspace(1) * %in
|
|
|
|
%den = load i8, i8 addrspace(1) * %den_ptr
|
|
|
|
%result = sdiv i8 %num, %den
|
|
|
|
%result.ext = sext i8 %result to i32
|
|
|
|
store i32 %result.ext, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}v_sdiv_i23:
|
|
|
|
; SI: v_rcp_f32
|
|
|
|
; SI: v_bfe_i32 [[BFE:v[0-9]+]], v{{[0-9]+}}, 0, 23
|
|
|
|
; SI: buffer_store_dword [[BFE]]
|
|
|
|
define void @v_sdiv_i23(i32 addrspace(1)* %out, i23 addrspace(1)* %in) {
|
|
|
|
%den_ptr = getelementptr i23, i23 addrspace(1)* %in, i23 1
|
|
|
|
%num = load i23, i23 addrspace(1) * %in
|
|
|
|
%den = load i23, i23 addrspace(1) * %den_ptr
|
|
|
|
%result = sdiv i23 %num, %den
|
|
|
|
%result.ext = sext i23 %result to i32
|
|
|
|
store i32 %result.ext, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}v_sdiv_i24:
|
|
|
|
; SI: v_rcp_f32
|
|
|
|
; SI: v_bfe_i32 [[BFE:v[0-9]+]], v{{[0-9]+}}, 0, 24
|
|
|
|
; SI: buffer_store_dword [[BFE]]
|
|
|
|
define void @v_sdiv_i24(i32 addrspace(1)* %out, i24 addrspace(1)* %in) {
|
|
|
|
%den_ptr = getelementptr i24, i24 addrspace(1)* %in, i24 1
|
|
|
|
%num = load i24, i24 addrspace(1) * %in
|
|
|
|
%den = load i24, i24 addrspace(1) * %den_ptr
|
|
|
|
%result = sdiv i24 %num, %den
|
|
|
|
%result.ext = sext i24 %result to i32
|
|
|
|
store i32 %result.ext, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}v_sdiv_i25:
|
|
|
|
; SI-NOT: v_rcp_f32
|
|
|
|
define void @v_sdiv_i25(i32 addrspace(1)* %out, i25 addrspace(1)* %in) {
|
|
|
|
%den_ptr = getelementptr i25, i25 addrspace(1)* %in, i25 1
|
|
|
|
%num = load i25, i25 addrspace(1) * %in
|
|
|
|
%den = load i25, i25 addrspace(1) * %den_ptr
|
|
|
|
%result = sdiv i25 %num, %den
|
|
|
|
%result.ext = sext i25 %result to i32
|
|
|
|
store i32 %result.ext, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-06-16 03:48:16 +08:00
|
|
|
; Tests for 64-bit divide bypass.
|
|
|
|
; define void @test_get_quotient(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
|
|
|
|
; %result = sdiv i64 %a, %b
|
|
|
|
; store i64 %result, i64 addrspace(1)* %out, align 8
|
|
|
|
; ret void
|
|
|
|
; }
|
|
|
|
|
|
|
|
; define void @test_get_remainder(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
|
|
|
|
; %result = srem i64 %a, %b
|
|
|
|
; store i64 %result, i64 addrspace(1)* %out, align 8
|
|
|
|
; ret void
|
|
|
|
; }
|
|
|
|
|
|
|
|
; define void @test_get_quotient_and_remainder(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
|
|
|
|
; %resultdiv = sdiv i64 %a, %b
|
|
|
|
; %resultrem = srem i64 %a, %b
|
|
|
|
; %result = add i64 %resultdiv, %resultrem
|
|
|
|
; store i64 %result, i64 addrspace(1)* %out, align 8
|
|
|
|
; ret void
|
|
|
|
; }
|