2016-08-04 02:17:35 +08:00
|
|
|
; RUN: llc -verify-machineinstrs -O0 -mcpu=ppc64 -mtriple=powerpc64-unknown-linux-gnu -fast-isel=false < %s | FileCheck %s
|
|
|
|
; RUN: llc -verify-machineinstrs -O0 -mcpu=g4 -mtriple=powerpc-apple-darwin8 < %s | FileCheck -check-prefix=DARWIN32 %s
|
|
|
|
; RUN: llc -verify-machineinstrs -O0 -mcpu=ppc970 -mtriple=powerpc64-apple-darwin8 < %s | FileCheck -check-prefix=DARWIN64 %s
|
2013-02-21 01:31:41 +08:00
|
|
|
|
|
|
|
; Test case for PR 14779: anonymous aggregates are not handled correctly.
|
2013-05-09 01:22:33 +08:00
|
|
|
; Darwin bug report PR 15821 is similar.
|
2013-02-21 01:31:41 +08:00
|
|
|
; The bug is triggered by passing a byval structure after an anonymous
|
|
|
|
; aggregate.
|
|
|
|
|
|
|
|
%tarray = type { i64, i8* }
|
|
|
|
|
|
|
|
define i8* @func1({ i64, i8* } %array, i8* %ptr) {
|
|
|
|
entry:
|
|
|
|
%array_ptr = extractvalue {i64, i8* } %array, 1
|
|
|
|
%cond = icmp eq i8* %array_ptr, %ptr
|
|
|
|
br i1 %cond, label %equal, label %unequal
|
|
|
|
equal:
|
|
|
|
ret i8* %array_ptr
|
|
|
|
unequal:
|
|
|
|
ret i8* %ptr
|
|
|
|
}
|
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: func1:
|
2015-04-24 02:30:38 +08:00
|
|
|
; CHECK: cmpld {{([0-9]+,)?}}4, 5
|
2013-06-14 04:23:34 +08:00
|
|
|
; CHECK-DAG: std 4, -[[OFFSET1:[0-9]+]]
|
|
|
|
; CHECK-DAG: std 5, -[[OFFSET2:[0-9]+]]
|
2013-02-21 01:31:41 +08:00
|
|
|
; CHECK: ld 3, -[[OFFSET1]](1)
|
|
|
|
; CHECK: ld 3, -[[OFFSET2]](1)
|
|
|
|
|
2013-05-09 01:22:33 +08:00
|
|
|
; DARWIN32: _func1:
|
|
|
|
; DARWIN32: mr
|
|
|
|
; DARWIN32: mr r[[REG1:[0-9]+]], r[[REGA:[0-9]+]]
|
|
|
|
; DARWIN32: mr r[[REG2:[0-9]+]], r[[REGB:[0-9]+]]
|
2015-04-24 02:30:38 +08:00
|
|
|
; DARWIN32: cmplw {{(cr[0-9]+,)?}}r[[REGA]], r[[REGB]]
|
2013-05-09 01:22:33 +08:00
|
|
|
; DARWIN32: stw r[[REG1]], -[[OFFSET1:[0-9]+]]
|
|
|
|
; DARWIN32: stw r[[REG2]], -[[OFFSET2:[0-9]+]]
|
|
|
|
; DARWIN32: lwz r3, -[[OFFSET1]]
|
|
|
|
; DARWIN32: lwz r3, -[[OFFSET2]]
|
|
|
|
|
|
|
|
; DARWIN64: _func1:
|
|
|
|
; DARWIN64: mr
|
|
|
|
; DARWIN64: mr r[[REG1:[0-9]+]], r[[REGA:[0-9]+]]
|
|
|
|
; DARWIN64: mr r[[REG2:[0-9]+]], r[[REGB:[0-9]+]]
|
2015-04-24 02:30:38 +08:00
|
|
|
; DARWIN64: cmpld {{(cr[0-9]+,)?}}r[[REGA]], r[[REGB]]
|
2013-05-09 01:22:33 +08:00
|
|
|
; DARWIN64: std r[[REG1]], -[[OFFSET1:[0-9]+]]
|
|
|
|
; DARWIN64: std r[[REG2]], -[[OFFSET2:[0-9]+]]
|
|
|
|
; DARWIN64: ld r3, -[[OFFSET1]]
|
|
|
|
; DARWIN64: ld r3, -[[OFFSET2]]
|
|
|
|
|
2013-02-21 01:31:41 +08:00
|
|
|
|
|
|
|
define i8* @func2({ i64, i8* } %array1, %tarray* byval %array2) {
|
|
|
|
entry:
|
|
|
|
%array1_ptr = extractvalue {i64, i8* } %array1, 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
|
|
|
%tmp = getelementptr inbounds %tarray, %tarray* %array2, i32 0, i32 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%array2_ptr = load i8*, i8** %tmp
|
2013-02-21 01:31:41 +08:00
|
|
|
%cond = icmp eq i8* %array1_ptr, %array2_ptr
|
|
|
|
br i1 %cond, label %equal, label %unequal
|
|
|
|
equal:
|
|
|
|
ret i8* %array1_ptr
|
|
|
|
unequal:
|
|
|
|
ret i8* %array2_ptr
|
|
|
|
}
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: func2:
|
In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled.
Recommiting with compiler time improvements
Recommitting after fixup of 32-bit aliasing sign offset bug in DAGCombiner.
* Simplify Consecutive Merge Store Candidate Search
Now that address aliasing is much less conservative, push through
simplified store merging search and chain alias analysis which only
checks for parallel stores through the chain subgraph. This is cleaner
as the separation of non-interfering loads/stores from the
store-merging logic.
When merging stores search up the chain through a single load, and
finds all possible stores by looking down from through a load and a
TokenFactor to all stores visited.
This improves the quality of the output SelectionDAG and the output
Codegen (save perhaps for some ARM cases where we correctly constructs
wider loads, but then promotes them to float operations which appear
but requires more expensive constant generation).
Some minor peephole optimizations to deal with improved SubDAG shapes (listed below)
Additional Minor Changes:
1. Finishes removing unused AliasLoad code
2. Unifies the chain aggregation in the merged stores across code
paths
3. Re-add the Store node to the worklist after calling
SimplifyDemandedBits.
4. Increase GatherAllAliasesMaxDepth from 6 to 18. That number is
arbitrary, but seems sufficient to not cause regressions in
tests.
5. Remove Chain dependencies of Memory operations on CopyfromReg
nodes as these are captured by data dependence
6. Forward loads-store values through tokenfactors containing
{CopyToReg,CopyFromReg} Values.
7. Peephole to convert buildvector of extract_vector_elt to
extract_subvector if possible (see
CodeGen/AArch64/store-merge.ll)
8. Store merging for the ARM target is restricted to 32-bit as
some in some contexts invalid 64-bit operations are being
generated. This can be removed once appropriate checks are
added.
This finishes the change Matt Arsenault started in r246307 and
jyknight's original patch.
Many tests required some changes as memory operations are now
reorderable, improving load-store forwarding. One test in
particular is worth noting:
CodeGen/PowerPC/ppc64-align-long-double.ll - Improved load-store
forwarding converts a load-store pair into a parallel store and
a memory-realized bitcast of the same value. However, because we
lose the sharing of the explicit and implicit store values we
must create another local store. A similar transformation
happens before SelectionDAG as well.
Reviewers: arsenm, hfinkel, tstellarAMD, jyknight, nhaehnle
llvm-svn: 297695
2017-03-14 08:34:14 +08:00
|
|
|
; CHECK: cmpld {{([0-9]+,)?}}4, 6
|
|
|
|
; CHECK-DAG: std 6, 72(1)
|
|
|
|
; CHECK-DAG: std 5, 64(1)
|
|
|
|
; CHECK-DAG: std 6, -[[OFFSET1:[0-9]+]]
|
2016-11-28 22:30:29 +08:00
|
|
|
; CHECK-DAG: std 4, -[[OFFSET2:[0-9]+]]
|
2013-02-21 01:31:41 +08:00
|
|
|
; CHECK: ld 3, -[[OFFSET2]](1)
|
|
|
|
; CHECK: ld 3, -[[OFFSET1]](1)
|
|
|
|
|
In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled.
Recommiting with compiler time improvements
Recommitting after fixup of 32-bit aliasing sign offset bug in DAGCombiner.
* Simplify Consecutive Merge Store Candidate Search
Now that address aliasing is much less conservative, push through
simplified store merging search and chain alias analysis which only
checks for parallel stores through the chain subgraph. This is cleaner
as the separation of non-interfering loads/stores from the
store-merging logic.
When merging stores search up the chain through a single load, and
finds all possible stores by looking down from through a load and a
TokenFactor to all stores visited.
This improves the quality of the output SelectionDAG and the output
Codegen (save perhaps for some ARM cases where we correctly constructs
wider loads, but then promotes them to float operations which appear
but requires more expensive constant generation).
Some minor peephole optimizations to deal with improved SubDAG shapes (listed below)
Additional Minor Changes:
1. Finishes removing unused AliasLoad code
2. Unifies the chain aggregation in the merged stores across code
paths
3. Re-add the Store node to the worklist after calling
SimplifyDemandedBits.
4. Increase GatherAllAliasesMaxDepth from 6 to 18. That number is
arbitrary, but seems sufficient to not cause regressions in
tests.
5. Remove Chain dependencies of Memory operations on CopyfromReg
nodes as these are captured by data dependence
6. Forward loads-store values through tokenfactors containing
{CopyToReg,CopyFromReg} Values.
7. Peephole to convert buildvector of extract_vector_elt to
extract_subvector if possible (see
CodeGen/AArch64/store-merge.ll)
8. Store merging for the ARM target is restricted to 32-bit as
some in some contexts invalid 64-bit operations are being
generated. This can be removed once appropriate checks are
added.
This finishes the change Matt Arsenault started in r246307 and
jyknight's original patch.
Many tests required some changes as memory operations are now
reorderable, improving load-store forwarding. One test in
particular is worth noting:
CodeGen/PowerPC/ppc64-align-long-double.ll - Improved load-store
forwarding converts a load-store pair into a parallel store and
a memory-realized bitcast of the same value. However, because we
lose the sharing of the explicit and implicit store values we
must create another local store. A similar transformation
happens before SelectionDAG as well.
Reviewers: arsenm, hfinkel, tstellarAMD, jyknight, nhaehnle
llvm-svn: 297695
2017-03-14 08:34:14 +08:00
|
|
|
; DARWIN32-LABEL: _func2
|
|
|
|
; DARWIN32-DAG: addi r[[REG8:[0-9]+]], r[[REGSP:[0-9]+]], 36
|
|
|
|
; DARWIN32-DAG: lwz r[[REG2:[0-9]+]], 44(r[[REGSP]])
|
2013-05-09 01:22:33 +08:00
|
|
|
; DARWIN32: mr
|
In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled.
Recommiting with compiler time improvements
Recommitting after fixup of 32-bit aliasing sign offset bug in DAGCombiner.
* Simplify Consecutive Merge Store Candidate Search
Now that address aliasing is much less conservative, push through
simplified store merging search and chain alias analysis which only
checks for parallel stores through the chain subgraph. This is cleaner
as the separation of non-interfering loads/stores from the
store-merging logic.
When merging stores search up the chain through a single load, and
finds all possible stores by looking down from through a load and a
TokenFactor to all stores visited.
This improves the quality of the output SelectionDAG and the output
Codegen (save perhaps for some ARM cases where we correctly constructs
wider loads, but then promotes them to float operations which appear
but requires more expensive constant generation).
Some minor peephole optimizations to deal with improved SubDAG shapes (listed below)
Additional Minor Changes:
1. Finishes removing unused AliasLoad code
2. Unifies the chain aggregation in the merged stores across code
paths
3. Re-add the Store node to the worklist after calling
SimplifyDemandedBits.
4. Increase GatherAllAliasesMaxDepth from 6 to 18. That number is
arbitrary, but seems sufficient to not cause regressions in
tests.
5. Remove Chain dependencies of Memory operations on CopyfromReg
nodes as these are captured by data dependence
6. Forward loads-store values through tokenfactors containing
{CopyToReg,CopyFromReg} Values.
7. Peephole to convert buildvector of extract_vector_elt to
extract_subvector if possible (see
CodeGen/AArch64/store-merge.ll)
8. Store merging for the ARM target is restricted to 32-bit as
some in some contexts invalid 64-bit operations are being
generated. This can be removed once appropriate checks are
added.
This finishes the change Matt Arsenault started in r246307 and
jyknight's original patch.
Many tests required some changes as memory operations are now
reorderable, improving load-store forwarding. One test in
particular is worth noting:
CodeGen/PowerPC/ppc64-align-long-double.ll - Improved load-store
forwarding converts a load-store pair into a parallel store and
a memory-realized bitcast of the same value. However, because we
lose the sharing of the explicit and implicit store values we
must create another local store. A similar transformation
happens before SelectionDAG as well.
Reviewers: arsenm, hfinkel, tstellarAMD, jyknight, nhaehnle
llvm-svn: 297695
2017-03-14 08:34:14 +08:00
|
|
|
; DARWIN32: mr r[[REG7:[0-9]+]], r5
|
|
|
|
; DARWIN32-DAG: cmplw {{(cr[0-9]+,)?}}r5, r[[REG2]]
|
|
|
|
; DARWIN32-DAG: stw r[[REG7]], -[[OFFSET1:[0-9]+]]
|
|
|
|
; DARWIN32-DAG: stw r[[REG2]], -[[OFFSET2:[0-9]+]]
|
|
|
|
; DARWIN32-DAG: lwz r3, -[[OFFSET1]]
|
|
|
|
; DARWIN32-DAG: lwz r3, -[[OFFSET2]]
|
|
|
|
|
2013-05-09 01:22:33 +08:00
|
|
|
|
|
|
|
; DARWIN64: _func2:
|
2014-07-21 06:26:40 +08:00
|
|
|
; DARWIN64: ld r[[REG2:[0-9]+]], 72(r1)
|
2013-05-09 01:22:33 +08:00
|
|
|
; DARWIN64: mr
|
|
|
|
; DARWIN64: mr r[[REG3:[0-9]+]], r[[REGA:[0-9]+]]
|
2015-04-24 02:30:38 +08:00
|
|
|
; DARWIN64: cmpld {{(cr[0-9]+,)?}}r[[REGA]], r[[REG2]]
|
2017-03-03 18:02:25 +08:00
|
|
|
; DARWIN64: std r[[REG2]], -[[OFFSET2:[0-9]+]]
|
In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled.
Recommiting with compiler time improvements
Recommitting after fixup of 32-bit aliasing sign offset bug in DAGCombiner.
* Simplify Consecutive Merge Store Candidate Search
Now that address aliasing is much less conservative, push through
simplified store merging search and chain alias analysis which only
checks for parallel stores through the chain subgraph. This is cleaner
as the separation of non-interfering loads/stores from the
store-merging logic.
When merging stores search up the chain through a single load, and
finds all possible stores by looking down from through a load and a
TokenFactor to all stores visited.
This improves the quality of the output SelectionDAG and the output
Codegen (save perhaps for some ARM cases where we correctly constructs
wider loads, but then promotes them to float operations which appear
but requires more expensive constant generation).
Some minor peephole optimizations to deal with improved SubDAG shapes (listed below)
Additional Minor Changes:
1. Finishes removing unused AliasLoad code
2. Unifies the chain aggregation in the merged stores across code
paths
3. Re-add the Store node to the worklist after calling
SimplifyDemandedBits.
4. Increase GatherAllAliasesMaxDepth from 6 to 18. That number is
arbitrary, but seems sufficient to not cause regressions in
tests.
5. Remove Chain dependencies of Memory operations on CopyfromReg
nodes as these are captured by data dependence
6. Forward loads-store values through tokenfactors containing
{CopyToReg,CopyFromReg} Values.
7. Peephole to convert buildvector of extract_vector_elt to
extract_subvector if possible (see
CodeGen/AArch64/store-merge.ll)
8. Store merging for the ARM target is restricted to 32-bit as
some in some contexts invalid 64-bit operations are being
generated. This can be removed once appropriate checks are
added.
This finishes the change Matt Arsenault started in r246307 and
jyknight's original patch.
Many tests required some changes as memory operations are now
reorderable, improving load-store forwarding. One test in
particular is worth noting:
CodeGen/PowerPC/ppc64-align-long-double.ll - Improved load-store
forwarding converts a load-store pair into a parallel store and
a memory-realized bitcast of the same value. However, because we
lose the sharing of the explicit and implicit store values we
must create another local store. A similar transformation
happens before SelectionDAG as well.
Reviewers: arsenm, hfinkel, tstellarAMD, jyknight, nhaehnle
llvm-svn: 297695
2017-03-14 08:34:14 +08:00
|
|
|
; DARWIN64: std r[[REG3]], -[[OFFSET1:[0-9]+]]
|
2013-05-09 01:22:33 +08:00
|
|
|
; DARWIN64: ld r3, -[[OFFSET1]]
|
|
|
|
; DARWIN64: ld r3, -[[OFFSET2]]
|
|
|
|
|
|
|
|
|
2013-02-21 01:31:41 +08:00
|
|
|
define i8* @func3({ i64, i8* }* byval %array1, %tarray* byval %array2) {
|
|
|
|
entry:
|
[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
|
|
|
%tmp1 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %array1, i32 0, i32 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%array1_ptr = load i8*, i8** %tmp1
|
[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
|
|
|
%tmp2 = getelementptr inbounds %tarray, %tarray* %array2, i32 0, i32 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%array2_ptr = load i8*, i8** %tmp2
|
2013-02-21 01:31:41 +08:00
|
|
|
%cond = icmp eq i8* %array1_ptr, %array2_ptr
|
|
|
|
br i1 %cond, label %equal, label %unequal
|
|
|
|
equal:
|
|
|
|
ret i8* %array1_ptr
|
|
|
|
unequal:
|
|
|
|
ret i8* %array2_ptr
|
|
|
|
}
|
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: func3:
|
In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled.
Recommiting with compiler time improvements
Recommitting after fixup of 32-bit aliasing sign offset bug in DAGCombiner.
* Simplify Consecutive Merge Store Candidate Search
Now that address aliasing is much less conservative, push through
simplified store merging search and chain alias analysis which only
checks for parallel stores through the chain subgraph. This is cleaner
as the separation of non-interfering loads/stores from the
store-merging logic.
When merging stores search up the chain through a single load, and
finds all possible stores by looking down from through a load and a
TokenFactor to all stores visited.
This improves the quality of the output SelectionDAG and the output
Codegen (save perhaps for some ARM cases where we correctly constructs
wider loads, but then promotes them to float operations which appear
but requires more expensive constant generation).
Some minor peephole optimizations to deal with improved SubDAG shapes (listed below)
Additional Minor Changes:
1. Finishes removing unused AliasLoad code
2. Unifies the chain aggregation in the merged stores across code
paths
3. Re-add the Store node to the worklist after calling
SimplifyDemandedBits.
4. Increase GatherAllAliasesMaxDepth from 6 to 18. That number is
arbitrary, but seems sufficient to not cause regressions in
tests.
5. Remove Chain dependencies of Memory operations on CopyfromReg
nodes as these are captured by data dependence
6. Forward loads-store values through tokenfactors containing
{CopyToReg,CopyFromReg} Values.
7. Peephole to convert buildvector of extract_vector_elt to
extract_subvector if possible (see
CodeGen/AArch64/store-merge.ll)
8. Store merging for the ARM target is restricted to 32-bit as
some in some contexts invalid 64-bit operations are being
generated. This can be removed once appropriate checks are
added.
This finishes the change Matt Arsenault started in r246307 and
jyknight's original patch.
Many tests required some changes as memory operations are now
reorderable, improving load-store forwarding. One test in
particular is worth noting:
CodeGen/PowerPC/ppc64-align-long-double.ll - Improved load-store
forwarding converts a load-store pair into a parallel store and
a memory-realized bitcast of the same value. However, because we
lose the sharing of the explicit and implicit store values we
must create another local store. A similar transformation
happens before SelectionDAG as well.
Reviewers: arsenm, hfinkel, tstellarAMD, jyknight, nhaehnle
llvm-svn: 297695
2017-03-14 08:34:14 +08:00
|
|
|
; CHECK: cmpld {{([0-9]+,)?}}4, 6
|
|
|
|
; CHECK-DAG: std 4, -[[OFFSET2:[0-9]+]](1)
|
|
|
|
; CHECK-DAG: std 6, -[[OFFSET1:[0-9]+]](1)
|
2013-02-21 01:31:41 +08:00
|
|
|
; CHECK: ld 3, -[[OFFSET2]](1)
|
|
|
|
; CHECK: ld 3, -[[OFFSET1]](1)
|
|
|
|
|
In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled.
Recommiting with compiler time improvements
Recommitting after fixup of 32-bit aliasing sign offset bug in DAGCombiner.
* Simplify Consecutive Merge Store Candidate Search
Now that address aliasing is much less conservative, push through
simplified store merging search and chain alias analysis which only
checks for parallel stores through the chain subgraph. This is cleaner
as the separation of non-interfering loads/stores from the
store-merging logic.
When merging stores search up the chain through a single load, and
finds all possible stores by looking down from through a load and a
TokenFactor to all stores visited.
This improves the quality of the output SelectionDAG and the output
Codegen (save perhaps for some ARM cases where we correctly constructs
wider loads, but then promotes them to float operations which appear
but requires more expensive constant generation).
Some minor peephole optimizations to deal with improved SubDAG shapes (listed below)
Additional Minor Changes:
1. Finishes removing unused AliasLoad code
2. Unifies the chain aggregation in the merged stores across code
paths
3. Re-add the Store node to the worklist after calling
SimplifyDemandedBits.
4. Increase GatherAllAliasesMaxDepth from 6 to 18. That number is
arbitrary, but seems sufficient to not cause regressions in
tests.
5. Remove Chain dependencies of Memory operations on CopyfromReg
nodes as these are captured by data dependence
6. Forward loads-store values through tokenfactors containing
{CopyToReg,CopyFromReg} Values.
7. Peephole to convert buildvector of extract_vector_elt to
extract_subvector if possible (see
CodeGen/AArch64/store-merge.ll)
8. Store merging for the ARM target is restricted to 32-bit as
some in some contexts invalid 64-bit operations are being
generated. This can be removed once appropriate checks are
added.
This finishes the change Matt Arsenault started in r246307 and
jyknight's original patch.
Many tests required some changes as memory operations are now
reorderable, improving load-store forwarding. One test in
particular is worth noting:
CodeGen/PowerPC/ppc64-align-long-double.ll - Improved load-store
forwarding converts a load-store pair into a parallel store and
a memory-realized bitcast of the same value. However, because we
lose the sharing of the explicit and implicit store values we
must create another local store. A similar transformation
happens before SelectionDAG as well.
Reviewers: arsenm, hfinkel, tstellarAMD, jyknight, nhaehnle
llvm-svn: 297695
2017-03-14 08:34:14 +08:00
|
|
|
; DARWIN32-LABEL: _func3:
|
|
|
|
; DARWIN32-DAG: stw r[[REG8:[0-9]+]], 44(r[[REGSP:[0-9]+]])
|
|
|
|
; DARWIN32-DAG: stw r[[REG5:[0-9]+]], 32(r[[REGSP]])
|
|
|
|
; DARWIN32-DAG: addi r[[REG5a:[0-9]+]], r[[REGSP:[0-9]+]], 36
|
|
|
|
; DARWIN32-DAG: addi r[[REG8a:[0-9]+]], r[[REGSP]], 24
|
|
|
|
; DARWIN32-DAG: lwz r[[REG5a:[0-9]+]], 44(r[[REGSP]])
|
|
|
|
; DARWIN32-DAG: lwz r[[REG8a:[0-9]+]], 32(r[[REGSP]])
|
|
|
|
; DARWIN32-DAG: cmplw {{(cr[0-9]+,)?}}r[[REG8a]], r[[REG5a]]
|
|
|
|
; DARWIN32-DAG: stw r[[REG5a]], -[[OFFSET1:[0-9]+]]
|
|
|
|
; DARWIN32-DAG: stw r[[REG8a]], -[[OFFSET2:[0-9]+]]
|
|
|
|
; DARWIN32-DAG: lwz r3, -[[OFFSET1:[0-9]+]]
|
|
|
|
; DARWIN32-DAG: lwz r3, -[[OFFSET2:[0-9]+]]
|
2013-05-09 01:22:33 +08:00
|
|
|
|
|
|
|
; DARWIN64: _func3:
|
2014-07-21 06:26:40 +08:00
|
|
|
; DARWIN64: ld r[[REG3:[0-9]+]], 72(r1)
|
|
|
|
; DARWIN64: ld r[[REG4:[0-9]+]], 56(r1)
|
2015-04-24 02:30:38 +08:00
|
|
|
; DARWIN64: cmpld {{(cr[0-9]+,)?}}r[[REG4]], r[[REG3]]
|
2013-05-09 01:22:33 +08:00
|
|
|
; DARWIN64: std r[[REG3]], -[[OFFSET1:[0-9]+]]
|
|
|
|
; DARWIN64: std r[[REG4]], -[[OFFSET2:[0-9]+]]
|
|
|
|
; DARWIN64: ld r3, -[[OFFSET2]]
|
|
|
|
; DARWIN64: ld r3, -[[OFFSET1]]
|
|
|
|
|
|
|
|
|
2013-02-21 01:31:41 +08:00
|
|
|
define i8* @func4(i64 %p1, i64 %p2, i64 %p3, i64 %p4,
|
|
|
|
i64 %p5, i64 %p6, i64 %p7, i64 %p8,
|
|
|
|
{ i64, i8* } %array1, %tarray* byval %array2) {
|
|
|
|
entry:
|
|
|
|
%array1_ptr = extractvalue {i64, i8* } %array1, 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
|
|
|
%tmp = getelementptr inbounds %tarray, %tarray* %array2, i32 0, i32 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%array2_ptr = load i8*, i8** %tmp
|
2013-02-21 01:31:41 +08:00
|
|
|
%cond = icmp eq i8* %array1_ptr, %array2_ptr
|
|
|
|
br i1 %cond, label %equal, label %unequal
|
|
|
|
equal:
|
|
|
|
ret i8* %array1_ptr
|
|
|
|
unequal:
|
|
|
|
ret i8* %array2_ptr
|
|
|
|
}
|
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: func4:
|
2014-07-21 06:26:40 +08:00
|
|
|
; CHECK: ld [[REG3:[0-9]+]], 136(1)
|
2013-02-21 01:31:41 +08:00
|
|
|
; CHECK: ld [[REG2:[0-9]+]], 120(1)
|
2015-04-24 02:30:38 +08:00
|
|
|
; CHECK: cmpld {{([0-9]+,)?}}[[REG2]], [[REG3]]
|
2013-02-21 01:31:41 +08:00
|
|
|
; CHECK: std [[REG3]], -[[OFFSET2:[0-9]+]](1)
|
2014-07-21 06:26:40 +08:00
|
|
|
; CHECK: std [[REG2]], -[[OFFSET1:[0-9]+]](1)
|
2013-02-21 01:31:41 +08:00
|
|
|
; CHECK: ld 3, -[[OFFSET1]](1)
|
|
|
|
; CHECK: ld 3, -[[OFFSET2]](1)
|
|
|
|
|
2013-05-09 01:22:33 +08:00
|
|
|
; DARWIN32: _func4:
|
|
|
|
; DARWIN32: lwz r[[REG4:[0-9]+]], 96(r1)
|
|
|
|
; DARWIN32: addi r[[REG1:[0-9]+]], r1, 100
|
|
|
|
; DARWIN32: lwz r[[REG3:[0-9]+]], 108(r1)
|
|
|
|
; DARWIN32: mr r[[REG2:[0-9]+]], r[[REG4]]
|
2015-04-24 02:30:38 +08:00
|
|
|
; DARWIN32: cmplw {{(cr[0-9]+,)?}}r[[REG4]], r[[REG3]]
|
2015-03-20 06:48:57 +08:00
|
|
|
; DARWIN32: stw r[[REG2]], -[[OFFSET1:[0-9]+]]
|
2013-05-09 01:22:33 +08:00
|
|
|
; DARWIN32: stw r[[REG3]], -[[OFFSET2:[0-9]+]]
|
|
|
|
; DARWIN32: lwz r[[REG1]], -[[OFFSET1]]
|
|
|
|
; DARWIN32: lwz r[[REG1]], -[[OFFSET2]]
|
|
|
|
|
|
|
|
; DARWIN64: _func4:
|
|
|
|
; DARWIN64: ld r[[REG2:[0-9]+]], 120(r1)
|
2014-07-21 06:26:40 +08:00
|
|
|
; DARWIN64: ld r[[REG3:[0-9]+]], 136(r1)
|
2013-05-09 01:22:33 +08:00
|
|
|
; DARWIN64: mr r[[REG4:[0-9]+]], r[[REG2]]
|
2015-04-24 02:30:38 +08:00
|
|
|
; DARWIN64: cmpld {{(cr[0-9]+,)?}}r[[REG2]], r[[REG3]]
|
2013-05-09 01:22:33 +08:00
|
|
|
; DARWIN64: std r[[REG4]], -[[OFFSET1:[0-9]+]]
|
|
|
|
; DARWIN64: std r[[REG3]], -[[OFFSET2:[0-9]+]]
|
|
|
|
; DARWIN64: ld r3, -[[OFFSET1]]
|
|
|
|
; DARWIN64: ld r3, -[[OFFSET2]]
|