2013-03-13 00:27:52 +08:00
|
|
|
; REQUIRES: asserts
|
[X86] Custom lower UINT_TO_FP from v4f32 to v4i32, and for v8f32 to v8i32 if
AVX2 is available.
According to IACA, the new lowering has a throughput of 8 cycles instead of 13
with the previous one.
Althought this lowering kicks in some SPECs benchmarks, the performance
improvement was within the noise.
Correctness testing has been done for the whole range of uint32_t with the
following program:
uint4 v = (uint4) {0,1,2,3};
uint32_t i;
//Check correctness over entire range for uint4 -> float4 conversion
for( i = 0; i < 1U << (32-2); i++ )
{
float4 t = test(v);
float4 c = correct(v);
if( 0xf != _mm_movemask_ps( t == c ))
{
printf( "Error @ %vx: %vf vs. %vf\n", v, c, t);
return -1;
}
v += 4;
}
Where "correct" is the old lowering and "test" the new one.
The patch adds a test case for the two custom lowering instruction.
It also modifies the vector cost model, which is why cast.ll and uitofp.ll are
modified.
2009-02-26-MachineLICMBug.ll is also modified because we now hoist 7
instructions instead of 4 (3 more constant loads).
rdar://problem/18153096>
llvm-svn: 221657
2014-11-11 10:23:47 +08:00
|
|
|
; RUN: llc < %s -march=x86-64 -mattr=+sse3,+sse4.1 -mcpu=penryn -stats 2>&1 | grep "7 machine-licm"
|
2013-08-24 04:39:19 +08:00
|
|
|
; RUN: llc < %s -march=x86-64 -mattr=+sse3,+sse4.1 -mcpu=penryn | FileCheck %s
|
2009-02-27 08:02:22 +08:00
|
|
|
; rdar://6627786
|
2010-03-26 08:07:25 +08:00
|
|
|
; rdar://7792037
|
2009-02-27 08:02:22 +08:00
|
|
|
|
|
|
|
target triple = "x86_64-apple-darwin10.0"
|
|
|
|
%struct.Key = type { i64 }
|
|
|
|
%struct.__Rec = type opaque
|
|
|
|
%struct.__vv = type { }
|
|
|
|
|
2010-01-12 01:23:56 +08:00
|
|
|
define %struct.__vv* @t(%struct.Key* %desc, i64 %p) nounwind ssp {
|
2009-02-27 08:02:22 +08:00
|
|
|
entry:
|
|
|
|
br label %bb4
|
|
|
|
|
|
|
|
bb4: ; preds = %bb.i, %bb26, %bb4, %entry
|
2010-03-26 08:07:25 +08:00
|
|
|
; CHECK: %bb4
|
2013-05-30 21:19:42 +08:00
|
|
|
; CHECK: xorl
|
2010-03-26 08:07:25 +08:00
|
|
|
; CHECK: callq
|
|
|
|
; CHECK: xorl
|
2013-05-30 21:19:42 +08:00
|
|
|
; CHECK: xorl
|
2013-10-16 07:33:07 +08:00
|
|
|
; CHECK: movq
|
2010-03-26 08:07:25 +08:00
|
|
|
|
2009-02-27 08:02:22 +08:00
|
|
|
%0 = call i32 (...)* @xxGetOffsetForCode(i32 undef) nounwind ; <i32> [#uses=0]
|
2010-01-12 01:23:56 +08:00
|
|
|
%ins = or i64 %p, 2097152 ; <i64> [#uses=1]
|
2009-02-27 08:02:22 +08:00
|
|
|
%1 = call i32 (...)* @xxCalculateMidType(%struct.Key* %desc, i32 0) nounwind ; <i32> [#uses=1]
|
|
|
|
%cond = icmp eq i32 %1, 1 ; <i1> [#uses=1]
|
|
|
|
br i1 %cond, label %bb26, label %bb4
|
|
|
|
|
|
|
|
bb26: ; preds = %bb4
|
|
|
|
%2 = and i64 %ins, 15728640 ; <i64> [#uses=1]
|
|
|
|
%cond.i = icmp eq i64 %2, 1048576 ; <i1> [#uses=1]
|
|
|
|
br i1 %cond.i, label %bb.i, label %bb4
|
|
|
|
|
|
|
|
bb.i: ; preds = %bb26
|
2015-02-28 05:17:42 +08:00
|
|
|
%3 = load i32, i32* null, align 4 ; <i32> [#uses=1]
|
2009-02-27 08:02:22 +08:00
|
|
|
%4 = uitofp i32 %3 to float ; <float> [#uses=1]
|
|
|
|
%.sum13.i = add i64 0, 4 ; <i64> [#uses=1]
|
[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
|
|
|
%5 = getelementptr i8, i8* null, i64 %.sum13.i ; <i8*> [#uses=1]
|
2009-02-27 08:02:22 +08:00
|
|
|
%6 = bitcast i8* %5 to i32* ; <i32*> [#uses=1]
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %6, align 4 ; <i32> [#uses=1]
|
2009-02-27 08:02:22 +08:00
|
|
|
%8 = uitofp i32 %7 to float ; <float> [#uses=1]
|
|
|
|
%.sum.i = add i64 0, 8 ; <i64> [#uses=1]
|
[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
|
|
|
%9 = getelementptr i8, i8* null, i64 %.sum.i ; <i8*> [#uses=1]
|
2009-02-27 08:02:22 +08:00
|
|
|
%10 = bitcast i8* %9 to i32* ; <i32*> [#uses=1]
|
2015-02-28 05:17:42 +08:00
|
|
|
%11 = load i32, i32* %10, align 4 ; <i32> [#uses=1]
|
2009-02-27 08:02:22 +08:00
|
|
|
%12 = uitofp i32 %11 to float ; <float> [#uses=1]
|
|
|
|
%13 = insertelement <4 x float> undef, float %4, i32 0 ; <<4 x float>> [#uses=1]
|
|
|
|
%14 = insertelement <4 x float> %13, float %8, i32 1 ; <<4 x float>> [#uses=1]
|
|
|
|
%15 = insertelement <4 x float> %14, float %12, i32 2 ; <<4 x float>> [#uses=1]
|
|
|
|
store <4 x float> %15, <4 x float>* null, align 16
|
|
|
|
br label %bb4
|
|
|
|
}
|
|
|
|
|
|
|
|
declare i32 @xxGetOffsetForCode(...)
|
|
|
|
|
|
|
|
declare i32 @xxCalculateMidType(...)
|