2012-03-23 01:09:04 +08:00
|
|
|
; RUN: opt < %s -indvars -S | FileCheck %s
|
2011-05-25 12:42:22 +08:00
|
|
|
;
|
|
|
|
; Make sure that indvars isn't inserting canonical IVs.
|
|
|
|
; This is kinda hard to do until linear function test replacement is removed.
|
|
|
|
|
|
|
|
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
|
|
|
|
|
|
|
|
define i32 @sum(i32* %arr, i32 %n) nounwind {
|
|
|
|
entry:
|
|
|
|
%precond = icmp slt i32 0, %n
|
|
|
|
br i1 %precond, label %ph, label %return
|
|
|
|
|
|
|
|
ph:
|
|
|
|
br label %loop
|
|
|
|
|
|
|
|
; CHECK: loop:
|
|
|
|
;
|
|
|
|
; We should only have 2 IVs.
|
|
|
|
; CHECK: phi
|
|
|
|
; CHECK: phi
|
|
|
|
; CHECK-NOT: phi
|
|
|
|
;
|
|
|
|
; sext should be eliminated while preserving gep inboundsness.
|
|
|
|
; CHECK-NOT: sext
|
|
|
|
; CHECK: getelementptr inbounds
|
2011-06-30 09:27:23 +08:00
|
|
|
; CHECK: exit:
|
2011-05-25 12:42:22 +08:00
|
|
|
loop:
|
|
|
|
%i.02 = phi i32 [ 0, %ph ], [ %iinc, %loop ]
|
|
|
|
%s.01 = phi i32 [ 0, %ph ], [ %sinc, %loop ]
|
|
|
|
%ofs = sext i32 %i.02 to i64
|
[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
|
|
|
%adr = getelementptr inbounds i32, i32* %arr, i64 %ofs
|
2015-02-28 05:17:42 +08:00
|
|
|
%val = load i32, i32* %adr
|
2011-05-25 12:42:22 +08:00
|
|
|
%sinc = add nsw i32 %s.01, %val
|
|
|
|
%iinc = add nsw i32 %i.02, 1
|
|
|
|
%cond = icmp slt i32 %iinc, %n
|
|
|
|
br i1 %cond, label %loop, label %exit
|
|
|
|
|
|
|
|
exit:
|
|
|
|
%s.lcssa = phi i32 [ %sinc, %loop ]
|
|
|
|
br label %return
|
|
|
|
|
|
|
|
return:
|
|
|
|
%s.0.lcssa = phi i32 [ %s.lcssa, %exit ], [ 0, %entry ]
|
|
|
|
ret i32 %s.0.lcssa
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @suml(i32* %arr, i32 %n) nounwind {
|
|
|
|
entry:
|
|
|
|
%precond = icmp slt i32 0, %n
|
|
|
|
br i1 %precond, label %ph, label %return
|
|
|
|
|
|
|
|
ph:
|
|
|
|
br label %loop
|
|
|
|
|
|
|
|
; CHECK: loop:
|
|
|
|
;
|
|
|
|
; We should only have 2 IVs.
|
|
|
|
; CHECK: phi
|
|
|
|
; CHECK: phi
|
|
|
|
; CHECK-NOT: phi
|
|
|
|
;
|
|
|
|
; %ofs sext should be eliminated while preserving gep inboundsness.
|
|
|
|
; CHECK-NOT: sext
|
|
|
|
; CHECK: getelementptr inbounds
|
|
|
|
; %vall sext should obviously not be eliminated
|
|
|
|
; CHECK: sext
|
2011-06-30 09:27:23 +08:00
|
|
|
; CHECK: exit:
|
2011-05-25 12:42:22 +08:00
|
|
|
loop:
|
|
|
|
%i.02 = phi i32 [ 0, %ph ], [ %iinc, %loop ]
|
|
|
|
%s.01 = phi i64 [ 0, %ph ], [ %sinc, %loop ]
|
|
|
|
%ofs = sext i32 %i.02 to i64
|
[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
|
|
|
%adr = getelementptr inbounds i32, i32* %arr, i64 %ofs
|
2015-02-28 05:17:42 +08:00
|
|
|
%val = load i32, i32* %adr
|
2011-05-25 12:42:22 +08:00
|
|
|
%vall = sext i32 %val to i64
|
|
|
|
%sinc = add nsw i64 %s.01, %vall
|
|
|
|
%iinc = add nsw i32 %i.02, 1
|
|
|
|
%cond = icmp slt i32 %iinc, %n
|
|
|
|
br i1 %cond, label %loop, label %exit
|
|
|
|
|
|
|
|
exit:
|
|
|
|
%s.lcssa = phi i64 [ %sinc, %loop ]
|
|
|
|
br label %return
|
|
|
|
|
|
|
|
return:
|
|
|
|
%s.0.lcssa = phi i64 [ %s.lcssa, %exit ], [ 0, %entry ]
|
|
|
|
ret i64 %s.0.lcssa
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @outofbounds(i32* %first, i32* %last, i32 %idx) nounwind {
|
|
|
|
%precond = icmp ne i32* %first, %last
|
|
|
|
br i1 %precond, label %ph, label %return
|
|
|
|
|
|
|
|
; CHECK: ph:
|
|
|
|
; It's not indvars' job to perform LICM on %ofs
|
|
|
|
; CHECK-NOT: sext
|
|
|
|
ph:
|
|
|
|
br label %loop
|
|
|
|
|
|
|
|
; CHECK: loop:
|
|
|
|
;
|
|
|
|
; Preserve exactly one pointer type IV.
|
|
|
|
; CHECK: phi i32*
|
|
|
|
; CHECK-NOT: phi
|
|
|
|
;
|
|
|
|
; Don't create any extra adds.
|
|
|
|
; CHECK-NOT: add
|
|
|
|
;
|
|
|
|
; Preserve gep inboundsness, and don't factor it.
|
[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
|
|
|
; CHECK: getelementptr inbounds i32, i32* %ptriv, i32 1
|
2011-05-25 12:42:22 +08:00
|
|
|
; CHECK-NOT: add
|
2011-06-30 09:27:23 +08:00
|
|
|
; CHECK: exit:
|
2011-05-25 12:42:22 +08:00
|
|
|
loop:
|
|
|
|
%ptriv = phi i32* [ %first, %ph ], [ %ptrpost, %loop ]
|
|
|
|
%ofs = sext i32 %idx to i64
|
[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
|
|
|
%adr = getelementptr inbounds i32, i32* %ptriv, i64 %ofs
|
2011-05-25 12:42:22 +08:00
|
|
|
store i32 3, i32* %adr
|
[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
|
|
|
%ptrpost = getelementptr inbounds i32, i32* %ptriv, i32 1
|
2011-05-25 12:42:22 +08:00
|
|
|
%cond = icmp ne i32* %ptrpost, %last
|
|
|
|
br i1 %cond, label %loop, label %exit
|
|
|
|
|
|
|
|
exit:
|
|
|
|
br label %return
|
|
|
|
|
|
|
|
return:
|
|
|
|
ret void
|
|
|
|
}
|
2011-06-29 11:13:40 +08:00
|
|
|
|
2011-07-20 10:08:58 +08:00
|
|
|
%structI = type { i32 }
|
2011-06-29 11:13:40 +08:00
|
|
|
|
2011-07-20 10:08:58 +08:00
|
|
|
define void @bitcastiv(i32 %start, i32 %limit, i32 %step, %structI* %base)
|
2011-06-29 11:13:40 +08:00
|
|
|
nounwind
|
|
|
|
{
|
|
|
|
entry:
|
|
|
|
br label %loop
|
|
|
|
|
|
|
|
; CHECK: loop:
|
|
|
|
;
|
|
|
|
; Preserve casts
|
|
|
|
; CHECK: phi i32
|
|
|
|
; CHECK: bitcast
|
|
|
|
; CHECK: getelementptr
|
2011-06-30 09:27:23 +08:00
|
|
|
; CHECK: exit:
|
2011-06-29 11:13:40 +08:00
|
|
|
loop:
|
|
|
|
%iv = phi i32 [%start, %entry], [%next, %loop]
|
2011-07-20 10:08:58 +08:00
|
|
|
%p = phi %structI* [%base, %entry], [%pinc, %loop]
|
[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
|
|
|
%adr = getelementptr %structI, %structI* %p, i32 0, i32 0
|
2011-06-29 11:13:40 +08:00
|
|
|
store i32 3, i32* %adr
|
2011-07-20 10:08:58 +08:00
|
|
|
%pp = bitcast %structI* %p to i32*
|
2011-06-29 11:13:40 +08:00
|
|
|
store i32 4, i32* %pp
|
[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
|
|
|
%pinc = getelementptr %structI, %structI* %p, i32 1
|
2011-06-29 11:13:40 +08:00
|
|
|
%next = add i32 %iv, 1
|
|
|
|
%cond = icmp ne i32 %next, %limit
|
|
|
|
br i1 %cond, label %loop, label %exit
|
|
|
|
|
|
|
|
exit:
|
2011-06-30 07:03:57 +08:00
|
|
|
ret void
|
|
|
|
}
|
2011-06-29 11:13:40 +08:00
|
|
|
|
2011-06-30 07:03:57 +08:00
|
|
|
define void @maxvisitor(i32 %limit, i32* %base) nounwind {
|
2011-06-30 09:27:23 +08:00
|
|
|
entry:
|
|
|
|
br label %loop
|
2011-06-30 07:03:57 +08:00
|
|
|
|
2011-07-01 03:02:17 +08:00
|
|
|
; Test inserting a truncate at a phi use.
|
|
|
|
;
|
2011-06-30 07:03:57 +08:00
|
|
|
; CHECK: loop:
|
|
|
|
; CHECK: phi i64
|
|
|
|
; CHECK: trunc
|
2011-06-30 09:27:23 +08:00
|
|
|
; CHECK: exit:
|
2011-06-30 07:03:57 +08:00
|
|
|
loop:
|
|
|
|
%idx = phi i32 [ 0, %entry ], [ %idx.next, %loop.inc ]
|
|
|
|
%max = phi i32 [ 0, %entry ], [ %max.next, %loop.inc ]
|
|
|
|
%idxprom = sext i32 %idx to i64
|
[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
|
|
|
%adr = getelementptr inbounds i32, i32* %base, i64 %idxprom
|
2015-02-28 05:17:42 +08:00
|
|
|
%val = load i32, i32* %adr
|
2011-06-30 07:03:57 +08:00
|
|
|
%cmp19 = icmp sgt i32 %val, %max
|
|
|
|
br i1 %cmp19, label %if.then, label %if.else
|
|
|
|
|
|
|
|
if.then:
|
|
|
|
br label %loop.inc
|
|
|
|
|
|
|
|
if.else:
|
|
|
|
br label %loop.inc
|
|
|
|
|
|
|
|
loop.inc:
|
|
|
|
%max.next = phi i32 [ %idx, %if.then ], [ %max, %if.else ]
|
|
|
|
%idx.next = add nsw i32 %idx, 1
|
|
|
|
%cmp = icmp slt i32 %idx.next, %limit
|
|
|
|
br i1 %cmp, label %loop, label %exit
|
|
|
|
|
|
|
|
exit:
|
2011-06-29 11:13:40 +08:00
|
|
|
ret void
|
2011-06-30 09:27:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define void @identityphi(i32 %limit) nounwind {
|
|
|
|
entry:
|
|
|
|
br label %loop
|
|
|
|
|
2011-07-01 03:02:17 +08:00
|
|
|
; Test an edge case of removing an identity phi that directly feeds
|
|
|
|
; back to the loop iv.
|
|
|
|
;
|
|
|
|
; CHECK: loop:
|
|
|
|
; CHECK-NOT: phi
|
|
|
|
; CHECK: exit:
|
2011-06-30 09:27:23 +08:00
|
|
|
loop:
|
|
|
|
%iv = phi i32 [ 0, %entry], [ %iv.next, %control ]
|
|
|
|
br i1 undef, label %if.then, label %control
|
|
|
|
|
|
|
|
if.then:
|
|
|
|
br label %control
|
|
|
|
|
|
|
|
control:
|
|
|
|
%iv.next = phi i32 [ %iv, %loop ], [ undef, %if.then ]
|
|
|
|
%cmp = icmp slt i32 %iv.next, %limit
|
|
|
|
br i1 %cmp, label %loop, label %exit
|
|
|
|
|
|
|
|
exit:
|
|
|
|
ret void
|
|
|
|
}
|
2011-07-01 03:02:17 +08:00
|
|
|
|
|
|
|
define i64 @cloneOr(i32 %limit, i64* %base) nounwind {
|
|
|
|
entry:
|
|
|
|
; ensure that the loop can't overflow
|
|
|
|
%halfLim = ashr i32 %limit, 2
|
|
|
|
br label %loop
|
|
|
|
|
2013-11-06 10:08:26 +08:00
|
|
|
; This test originally checked that the OR instruction was cloned. Now the
|
|
|
|
; ScalarEvolution is able to understand the loop evolution and that '%iv' at the
|
|
|
|
; end of the loop is an even value. Thus '%val' is computed at the end of the
|
|
|
|
; loop and the OR instruction is replaced by an ADD keeping the result
|
|
|
|
; equivalent.
|
2011-07-01 03:02:17 +08:00
|
|
|
;
|
2014-09-17 22:10:33 +08:00
|
|
|
; CHECK: sext
|
2011-07-01 03:02:17 +08:00
|
|
|
; CHECK: loop:
|
|
|
|
; CHECK: phi i64
|
|
|
|
; CHECK-NOT: sext
|
2014-09-17 22:10:33 +08:00
|
|
|
; CHECK: icmp slt i64
|
2011-07-01 03:02:17 +08:00
|
|
|
; CHECK: exit:
|
2013-11-06 10:08:26 +08:00
|
|
|
; CHECK: add i64
|
2011-07-01 03:02:17 +08:00
|
|
|
loop:
|
|
|
|
%iv = phi i32 [ 0, %entry], [ %iv.next, %loop ]
|
|
|
|
%t1 = sext i32 %iv to i64
|
[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
|
|
|
%adr = getelementptr i64, i64* %base, i64 %t1
|
2015-02-28 05:17:42 +08:00
|
|
|
%val = load i64, i64* %adr
|
2011-07-01 03:02:17 +08:00
|
|
|
%t2 = or i32 %iv, 1
|
|
|
|
%t3 = sext i32 %t2 to i64
|
|
|
|
%iv.next = add i32 %iv, 2
|
|
|
|
%cmp = icmp slt i32 %iv.next, %halfLim
|
|
|
|
br i1 %cmp, label %loop, label %exit
|
|
|
|
|
|
|
|
exit:
|
|
|
|
%result = and i64 %val, %t3
|
|
|
|
ret i64 %result
|
|
|
|
}
|
2011-07-02 10:34:25 +08:00
|
|
|
|
|
|
|
; The i induction variable looks like a wrap-around, but it really is just
|
|
|
|
; a simple affine IV. Make sure that indvars simplifies through.
|
|
|
|
define i32 @indirectRecurrence() nounwind {
|
|
|
|
entry:
|
|
|
|
br label %loop
|
|
|
|
|
|
|
|
; ReplaceLoopExitValue should fold the return value to constant 9.
|
|
|
|
; CHECK: loop:
|
|
|
|
; CHECK: phi i32
|
|
|
|
; CHECK: ret i32 9
|
|
|
|
loop:
|
|
|
|
%j.0 = phi i32 [ 1, %entry ], [ %j.next, %cond_true ]
|
|
|
|
%i.0 = phi i32 [ 0, %entry ], [ %j.0, %cond_true ]
|
|
|
|
%tmp = icmp ne i32 %j.0, 10
|
|
|
|
br i1 %tmp, label %cond_true, label %return
|
|
|
|
|
|
|
|
cond_true:
|
|
|
|
%j.next = add i32 %j.0, 1
|
|
|
|
br label %loop
|
|
|
|
|
|
|
|
return:
|
|
|
|
ret i32 %i.0
|
|
|
|
}
|
2011-07-07 04:50:43 +08:00
|
|
|
|
|
|
|
; Eliminate the congruent phis j, k, and l.
|
|
|
|
; Eliminate the redundant IV increments k.next and l.next.
|
|
|
|
; Two phis should remain, one starting at %init, and one at %init1.
|
|
|
|
; Two increments should remain, one by %step and one by %step1.
|
|
|
|
; CHECK: loop:
|
|
|
|
; CHECK: phi i32
|
|
|
|
; CHECK: phi i32
|
|
|
|
; CHECK-NOT: phi
|
|
|
|
; CHECK: add i32
|
|
|
|
; CHECK: add i32
|
2011-10-11 10:28:51 +08:00
|
|
|
; CHECK: add i32
|
2011-07-07 04:50:43 +08:00
|
|
|
; CHECK-NOT: add
|
|
|
|
; CHECK: return:
|
|
|
|
;
|
|
|
|
; Five live-outs should remain.
|
|
|
|
; CHECK: lcssa = phi
|
|
|
|
; CHECK: lcssa = phi
|
|
|
|
; CHECK: lcssa = phi
|
|
|
|
; CHECK: lcssa = phi
|
|
|
|
; CHECK: lcssa = phi
|
|
|
|
; CHECK-NOT: phi
|
|
|
|
; CHECK: ret
|
|
|
|
define i32 @isomorphic(i32 %init, i32 %step, i32 %lim) nounwind {
|
|
|
|
entry:
|
|
|
|
%step1 = add i32 %step, 1
|
|
|
|
%init1 = add i32 %init, %step1
|
|
|
|
%l.0 = sub i32 %init1, %step1
|
|
|
|
br label %loop
|
|
|
|
|
|
|
|
loop:
|
|
|
|
%ii = phi i32 [ %init1, %entry ], [ %ii.next, %loop ]
|
|
|
|
%i = phi i32 [ %init, %entry ], [ %ii, %loop ]
|
|
|
|
%j = phi i32 [ %init, %entry ], [ %j.next, %loop ]
|
|
|
|
%k = phi i32 [ %init1, %entry ], [ %k.next, %loop ]
|
|
|
|
%l = phi i32 [ %l.0, %entry ], [ %l.next, %loop ]
|
|
|
|
%ii.next = add i32 %ii, %step1
|
|
|
|
%j.next = add i32 %j, %step1
|
|
|
|
%k.next = add i32 %k, %step1
|
|
|
|
%l.step = add i32 %l, %step
|
|
|
|
%l.next = add i32 %l.step, 1
|
|
|
|
%cmp = icmp ne i32 %ii.next, %lim
|
|
|
|
br i1 %cmp, label %loop, label %return
|
|
|
|
|
|
|
|
return:
|
|
|
|
%sum1 = add i32 %i, %j.next
|
|
|
|
%sum2 = add i32 %sum1, %k.next
|
|
|
|
%sum3 = add i32 %sum1, %l.step
|
|
|
|
%sum4 = add i32 %sum1, %l.next
|
|
|
|
ret i32 %sum4
|
|
|
|
}
|
2011-07-20 10:08:58 +08:00
|
|
|
|
|
|
|
; Test a GEP IV that is derived from another GEP IV by a nop gep that
|
|
|
|
; lowers the type without changing the expression.
|
|
|
|
%structIF = type { i32, float }
|
|
|
|
|
|
|
|
define void @congruentgepiv(%structIF* %base) nounwind uwtable ssp {
|
|
|
|
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
|
|
|
%first = getelementptr inbounds %structIF, %structIF* %base, i64 0, i32 0
|
2011-07-20 10:08:58 +08:00
|
|
|
br label %loop
|
|
|
|
|
2011-07-20 10:14:37 +08:00
|
|
|
; CHECK: loop:
|
|
|
|
; CHECK: phi %structIF*
|
2012-01-07 09:12:09 +08:00
|
|
|
; CHECK-NOT: phi
|
2011-07-20 10:14:37 +08:00
|
|
|
; CHECK: getelementptr inbounds
|
2012-01-07 09:12:09 +08:00
|
|
|
; CHECK-NOT: getelementptr
|
2011-07-20 10:14:37 +08:00
|
|
|
; CHECK: exit:
|
2011-07-20 10:08:58 +08:00
|
|
|
loop:
|
|
|
|
%ptr.iv = phi %structIF* [ %ptr.inc, %latch ], [ %base, %entry ]
|
|
|
|
%next = phi i32* [ %next.inc, %latch ], [ %first, %entry ]
|
2011-07-20 10:14:37 +08:00
|
|
|
store i32 4, i32* %next
|
2011-07-20 10:08:58 +08:00
|
|
|
br i1 undef, label %latch, label %exit
|
|
|
|
|
|
|
|
latch: ; preds = %for.inc50.i
|
[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
|
|
|
%ptr.inc = getelementptr inbounds %structIF, %structIF* %ptr.iv, i64 1
|
|
|
|
%next.inc = getelementptr inbounds %structIF, %structIF* %ptr.inc, i64 0, i32 0
|
2011-07-20 10:08:58 +08:00
|
|
|
br label %loop
|
|
|
|
|
|
|
|
exit:
|
|
|
|
ret void
|
|
|
|
}
|
2011-07-20 13:32:06 +08:00
|
|
|
|
|
|
|
; Test a widened IV that is used by a phi on different paths within the loop.
|
|
|
|
;
|
|
|
|
; CHECK: for.body:
|
|
|
|
; CHECK: phi i64
|
|
|
|
; CHECK: trunc i64
|
|
|
|
; CHECK: if.then:
|
|
|
|
; CHECK: for.inc:
|
|
|
|
; CHECK: phi i32
|
|
|
|
; CHECK: for.end:
|
|
|
|
define void @phiUsesTrunc() nounwind {
|
|
|
|
entry:
|
|
|
|
br i1 undef, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body:
|
|
|
|
%iv = phi i32 [ %inc, %for.inc ], [ 1, %entry ]
|
|
|
|
br i1 undef, label %if.then, label %if.else
|
|
|
|
|
|
|
|
if.then:
|
|
|
|
br i1 undef, label %if.then33, label %for.inc
|
|
|
|
|
|
|
|
if.then33:
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
if.else:
|
|
|
|
br i1 undef, label %if.then97, label %for.inc
|
|
|
|
|
|
|
|
if.then97:
|
|
|
|
%idxprom100 = sext i32 %iv to i64
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc:
|
|
|
|
%kmin.1 = phi i32 [ %iv, %if.then33 ], [ 0, %if.then ], [ %iv, %if.then97 ], [ 0, %if.else ]
|
|
|
|
%inc = add nsw i32 %iv, 1
|
|
|
|
br i1 undef, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.end:
|
|
|
|
ret void
|
|
|
|
}
|