2014-09-11 01:58:16 +08:00
|
|
|
; RUN: opt < %s -O1 -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine -S | FileCheck %s
|
2013-02-22 06:39:03 +08:00
|
|
|
|
|
|
|
target datalayout = "e-p:32:32:32-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:64:128-a0:0:64-n32-S64"
|
|
|
|
|
|
|
|
%struct.anon = type { [100 x i32], i32, [100 x i32] }
|
2013-02-23 20:48:30 +08:00
|
|
|
%struct.anon.0 = type { [100 x [100 x i32]], i32, [100 x [100 x i32]] }
|
2013-02-22 06:39:03 +08:00
|
|
|
|
|
|
|
@Foo = common global %struct.anon zeroinitializer, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
@Bar = common global %struct.anon.0 zeroinitializer, align 4
|
|
|
|
|
2013-02-22 06:39:03 +08:00
|
|
|
@PB = external global i32*
|
|
|
|
@PA = external global i32*
|
|
|
|
|
2013-02-23 20:48:30 +08:00
|
|
|
|
2016-06-02 01:16:46 +08:00
|
|
|
;; === First, the tests that should always vectorize, whether statically or by adding run-time checks ===
|
2013-02-23 20:48:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
; /// Different objects, positive induction, constant distance
|
2013-02-22 06:39:03 +08:00
|
|
|
; int noAlias01 (int a) {
|
|
|
|
; int i;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
|
|
|
; Foo.A[i] = Foo.B[i] + a;
|
|
|
|
; return Foo.A[a];
|
|
|
|
; }
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @noAlias01(
|
2013-02-22 06:39:03 +08:00
|
|
|
; CHECK: add nsw <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-22 06:39:03 +08:00
|
|
|
|
|
|
|
define i32 @noAlias01(i32 %a) nounwind {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %i, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %1
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %arrayidx, align 4
|
|
|
|
%3 = load i32, i32* %a.addr, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%add = add nsw i32 %2, %3
|
2015-02-28 05:17:42 +08:00
|
|
|
%4 = load i32, i32* %i, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx1 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %4
|
2013-02-22 06:39:03 +08:00
|
|
|
store i32 %add, i32* %arrayidx1, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%inc = add nsw i32 %5, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%6 = load i32, i32* %a.addr, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %arrayidx2, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
ret i32 %7
|
|
|
|
}
|
|
|
|
|
2013-02-23 20:48:30 +08:00
|
|
|
; /// Different objects, positive induction with widening slide
|
2013-02-23 00:18:31 +08:00
|
|
|
; int noAlias02 (int a) {
|
|
|
|
; int i;
|
|
|
|
; for (i=0; i<SIZE-10; i++)
|
|
|
|
; Foo.A[i] = Foo.B[i+10] + a;
|
|
|
|
; return Foo.A[a];
|
|
|
|
; }
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @noAlias02(
|
2013-02-23 00:18:31 +08:00
|
|
|
; CHECK: add nsw <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-23 00:18:31 +08:00
|
|
|
|
|
|
|
define i32 @noAlias02(i32 %a) {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-23 00:18:31 +08:00
|
|
|
%cmp = icmp slt i32 %0, 90
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %i, align 4
|
2013-02-23 00:18:31 +08:00
|
|
|
%add = add nsw i32 %1, 10
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %add
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %arrayidx, align 4
|
|
|
|
%3 = load i32, i32* %a.addr, align 4
|
2013-02-23 00:18:31 +08:00
|
|
|
%add1 = add nsw i32 %2, %3
|
2015-02-28 05:17:42 +08:00
|
|
|
%4 = load i32, i32* %i, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %4
|
2013-02-23 00:18:31 +08:00
|
|
|
store i32 %add1, i32* %arrayidx2, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %i, align 4
|
2013-02-23 00:18:31 +08:00
|
|
|
%inc = add nsw i32 %5, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%6 = load i32, i32* %a.addr, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %arrayidx3, align 4
|
2013-02-23 00:18:31 +08:00
|
|
|
ret i32 %7
|
|
|
|
}
|
|
|
|
|
2013-02-23 20:48:30 +08:00
|
|
|
; /// Different objects, positive induction with shortening slide
|
2013-02-23 00:18:31 +08:00
|
|
|
; int noAlias03 (int a) {
|
|
|
|
; int i;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
|
|
|
; Foo.A[i+10] = Foo.B[i] + a;
|
|
|
|
; return Foo.A[a];
|
|
|
|
; }
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @noAlias03(
|
2013-02-23 00:18:31 +08:00
|
|
|
; CHECK: add nsw <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-23 00:18:31 +08:00
|
|
|
|
|
|
|
define i32 @noAlias03(i32 %a) {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-23 00:18:31 +08:00
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %i, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %1
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %arrayidx, align 4
|
|
|
|
%3 = load i32, i32* %a.addr, align 4
|
2013-02-23 00:18:31 +08:00
|
|
|
%add = add nsw i32 %2, %3
|
2015-02-28 05:17:42 +08:00
|
|
|
%4 = load i32, i32* %i, align 4
|
2013-02-23 00:18:31 +08:00
|
|
|
%add1 = add nsw i32 %4, 10
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %add1
|
2013-02-23 00:18:31 +08:00
|
|
|
store i32 %add, i32* %arrayidx2, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %i, align 4
|
2013-02-23 00:18:31 +08:00
|
|
|
%inc = add nsw i32 %5, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%6 = load i32, i32* %a.addr, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %arrayidx3, align 4
|
2013-02-23 00:18:31 +08:00
|
|
|
ret i32 %7
|
|
|
|
}
|
|
|
|
|
2013-02-23 20:48:30 +08:00
|
|
|
; /// Pointer access, positive stride, run-time check added
|
|
|
|
; int noAlias04 (int a) {
|
2013-02-22 06:39:03 +08:00
|
|
|
; int i;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
2013-02-23 20:48:30 +08:00
|
|
|
; *(PA+i) = *(PB+i) + a;
|
|
|
|
; return *(PA+a);
|
2013-02-22 06:39:03 +08:00
|
|
|
; }
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @noAlias04(
|
2013-02-22 06:39:03 +08:00
|
|
|
; CHECK-NOT: add nsw <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-23 20:48:30 +08:00
|
|
|
;
|
|
|
|
; TODO: This test vectorizes (with run-time check) on real targets with -O3)
|
|
|
|
; Check why it's not being vectorized even when forcing vectorization
|
2013-02-22 06:39:03 +08:00
|
|
|
|
2013-02-23 20:48:30 +08:00
|
|
|
define i32 @noAlias04(i32 %a) #0 {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32*, i32** @PB, align 4
|
|
|
|
%2 = load i32, i32* %i, align 4
|
[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
|
|
|
%add.ptr = getelementptr inbounds i32, i32* %1, i32 %2
|
2015-02-28 05:17:42 +08:00
|
|
|
%3 = load i32, i32* %add.ptr, align 4
|
|
|
|
%4 = load i32, i32* %a.addr, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%add = add nsw i32 %3, %4
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32*, i32** @PA, align 4
|
|
|
|
%6 = load i32, i32* %i, align 4
|
[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
|
|
|
%add.ptr1 = getelementptr inbounds i32, i32* %5, i32 %6
|
2013-02-23 20:48:30 +08:00
|
|
|
store i32 %add, i32* %add.ptr1, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%inc = add nsw i32 %7, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%8 = load i32*, i32** @PA, align 4
|
|
|
|
%9 = load i32, i32* %a.addr, align 4
|
[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
|
|
|
%add.ptr2 = getelementptr inbounds i32, i32* %8, i32 %9
|
2015-02-28 05:17:42 +08:00
|
|
|
%10 = load i32, i32* %add.ptr2, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
ret i32 %10
|
|
|
|
}
|
|
|
|
|
|
|
|
; /// Different objects, positive induction, multi-array
|
|
|
|
; int noAlias05 (int a) {
|
|
|
|
; int i, N=10;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
|
|
|
; Bar.A[N][i] = Bar.B[N][i] + a;
|
|
|
|
; return Bar.A[N][a];
|
|
|
|
; }
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @noAlias05(
|
2013-02-23 20:48:30 +08:00
|
|
|
; CHECK: add nsw <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-23 20:48:30 +08:00
|
|
|
|
|
|
|
define i32 @noAlias05(i32 %a) #0 {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
%N = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 10, i32* %N, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %i, align 4
|
|
|
|
%2 = load i32, i32* %N, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 2), i32 0, i32 %2
|
[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
|
|
|
%arrayidx1 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx, i32 0, i32 %1
|
2015-02-28 05:17:42 +08:00
|
|
|
%3 = load i32, i32* %arrayidx1, align 4
|
|
|
|
%4 = load i32, i32* %a.addr, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%add = add nsw i32 %3, %4
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %i, align 4
|
|
|
|
%6 = load i32, i32* %N, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx2 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %6
|
[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
|
|
|
%arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx2, i32 0, i32 %5
|
2013-02-23 20:48:30 +08:00
|
|
|
store i32 %add, i32* %arrayidx3, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%inc = add nsw i32 %7, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%8 = load i32, i32* %a.addr, align 4
|
|
|
|
%9 = load i32, i32* %N, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx4 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %9
|
[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
|
|
|
%arrayidx5 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx4, i32 0, i32 %8
|
2015-02-28 05:17:42 +08:00
|
|
|
%10 = load i32, i32* %arrayidx5, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
ret i32 %10
|
|
|
|
}
|
|
|
|
|
|
|
|
; /// Same objects, positive induction, multi-array, different sub-elements
|
|
|
|
; int noAlias06 (int a) {
|
|
|
|
; int i, N=10;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
|
|
|
; Bar.A[N][i] = Bar.A[N+1][i] + a;
|
|
|
|
; return Bar.A[N][a];
|
|
|
|
; }
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @noAlias06(
|
2013-02-23 20:48:30 +08:00
|
|
|
; CHECK: add nsw <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-23 20:48:30 +08:00
|
|
|
|
|
|
|
define i32 @noAlias06(i32 %a) #0 {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
%N = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 10, i32* %N, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %i, align 4
|
|
|
|
%2 = load i32, i32* %N, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%add = add nsw i32 %2, 1
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %add
|
[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
|
|
|
%arrayidx1 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx, i32 0, i32 %1
|
2015-02-28 05:17:42 +08:00
|
|
|
%3 = load i32, i32* %arrayidx1, align 4
|
|
|
|
%4 = load i32, i32* %a.addr, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%add2 = add nsw i32 %3, %4
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %i, align 4
|
|
|
|
%6 = load i32, i32* %N, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx3 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %6
|
[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
|
|
|
%arrayidx4 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx3, i32 0, i32 %5
|
2013-02-23 20:48:30 +08:00
|
|
|
store i32 %add2, i32* %arrayidx4, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%inc = add nsw i32 %7, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%8 = load i32, i32* %a.addr, align 4
|
|
|
|
%9 = load i32, i32* %N, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx5 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %9
|
[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
|
|
|
%arrayidx6 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx5, i32 0, i32 %8
|
2015-02-28 05:17:42 +08:00
|
|
|
%10 = load i32, i32* %arrayidx6, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
ret i32 %10
|
|
|
|
}
|
|
|
|
|
|
|
|
; /// Different objects, negative induction, constant distance
|
|
|
|
; int noAlias07 (int a) {
|
|
|
|
; int i;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
|
|
|
; Foo.A[SIZE-i-1] = Foo.B[SIZE-i-1] + a;
|
|
|
|
; return Foo.A[a];
|
|
|
|
; }
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @noAlias07(
|
2013-11-02 06:18:19 +08:00
|
|
|
; CHECK: store <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-23 20:48:30 +08:00
|
|
|
define i32 @noAlias07(i32 %a) #0 {
|
2013-02-22 06:39:03 +08:00
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%sub = sub nsw i32 100, %1
|
|
|
|
%sub1 = sub nsw i32 %sub, 1
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %sub1
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %arrayidx, align 4
|
|
|
|
%3 = load i32, i32* %a.addr, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%add = add nsw i32 %2, %3
|
2015-02-28 05:17:42 +08:00
|
|
|
%4 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%sub2 = sub nsw i32 100, %4
|
|
|
|
%sub3 = sub nsw i32 %sub2, 1
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx4 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %sub3
|
2013-02-23 20:48:30 +08:00
|
|
|
store i32 %add, i32* %arrayidx4, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%inc = add nsw i32 %5, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%6 = load i32, i32* %a.addr, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx5 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %arrayidx5, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
ret i32 %7
|
|
|
|
}
|
|
|
|
|
|
|
|
; /// Different objects, negative induction, shortening slide
|
|
|
|
; int noAlias08 (int a) {
|
|
|
|
; int i;
|
|
|
|
; for (i=0; i<SIZE-10; i++)
|
|
|
|
; Foo.A[SIZE-i-1] = Foo.B[SIZE-i-10] + a;
|
|
|
|
; return Foo.A[a];
|
|
|
|
; }
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @noAlias08(
|
2016-09-27 01:08:37 +08:00
|
|
|
; CHECK: load <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-23 20:48:30 +08:00
|
|
|
|
|
|
|
define i32 @noAlias08(i32 %a) #0 {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%cmp = icmp slt i32 %0, 90
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%sub = sub nsw i32 100, %1
|
|
|
|
%sub1 = sub nsw i32 %sub, 10
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %sub1
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %arrayidx, align 4
|
|
|
|
%3 = load i32, i32* %a.addr, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%add = add nsw i32 %2, %3
|
2015-02-28 05:17:42 +08:00
|
|
|
%4 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%sub2 = sub nsw i32 100, %4
|
|
|
|
%sub3 = sub nsw i32 %sub2, 1
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx4 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %sub3
|
2013-02-23 20:48:30 +08:00
|
|
|
store i32 %add, i32* %arrayidx4, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%inc = add nsw i32 %5, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%6 = load i32, i32* %a.addr, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx5 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %arrayidx5, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
ret i32 %7
|
|
|
|
}
|
|
|
|
|
2013-02-23 20:48:30 +08:00
|
|
|
; /// Different objects, negative induction, widening slide
|
|
|
|
; int noAlias09 (int a) {
|
2013-02-23 00:18:31 +08:00
|
|
|
; int i;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
2013-02-23 20:48:30 +08:00
|
|
|
; Foo.A[SIZE-i-10] = Foo.B[SIZE-i-1] + a;
|
2013-02-23 00:18:31 +08:00
|
|
|
; return Foo.A[a];
|
|
|
|
; }
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @noAlias09(
|
2016-09-27 01:08:37 +08:00
|
|
|
; CHECK: load <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-23 00:18:31 +08:00
|
|
|
|
2013-02-23 20:48:30 +08:00
|
|
|
define i32 @noAlias09(i32 %a) #0 {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%sub = sub nsw i32 100, %1
|
|
|
|
%sub1 = sub nsw i32 %sub, 1
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %sub1
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %arrayidx, align 4
|
|
|
|
%3 = load i32, i32* %a.addr, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%add = add nsw i32 %2, %3
|
2015-02-28 05:17:42 +08:00
|
|
|
%4 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%sub2 = sub nsw i32 100, %4
|
|
|
|
%sub3 = sub nsw i32 %sub2, 10
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx4 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %sub3
|
2013-02-23 20:48:30 +08:00
|
|
|
store i32 %add, i32* %arrayidx4, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%inc = add nsw i32 %5, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%6 = load i32, i32* %a.addr, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx5 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %arrayidx5, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
ret i32 %7
|
|
|
|
}
|
|
|
|
|
|
|
|
; /// Pointer access, negative stride, run-time check added
|
|
|
|
; int noAlias10 (int a) {
|
|
|
|
; int i;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
|
|
|
; *(PA+SIZE-i-1) = *(PB+SIZE-i-1) + a;
|
|
|
|
; return *(PA+a);
|
|
|
|
; }
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @noAlias10(
|
2014-01-19 23:24:22 +08:00
|
|
|
; CHECK-NOT: sub {{.*}} <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-23 20:48:30 +08:00
|
|
|
;
|
|
|
|
; TODO: This test vectorizes (with run-time check) on real targets with -O3)
|
|
|
|
; Check why it's not being vectorized even when forcing vectorization
|
|
|
|
|
|
|
|
define i32 @noAlias10(i32 %a) #0 {
|
2013-02-23 00:18:31 +08:00
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-23 00:18:31 +08:00
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32*, i32** @PB, align 4
|
[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
|
|
|
%add.ptr = getelementptr inbounds i32, i32* %1, i32 100
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%idx.neg = sub i32 0, %2
|
[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
|
|
|
%add.ptr1 = getelementptr inbounds i32, i32* %add.ptr, i32 %idx.neg
|
|
|
|
%add.ptr2 = getelementptr inbounds i32, i32* %add.ptr1, i32 -1
|
2015-02-28 05:17:42 +08:00
|
|
|
%3 = load i32, i32* %add.ptr2, align 4
|
|
|
|
%4 = load i32, i32* %a.addr, align 4
|
2013-02-23 00:18:31 +08:00
|
|
|
%add = add nsw i32 %3, %4
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32*, i32** @PA, align 4
|
[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
|
|
|
%add.ptr3 = getelementptr inbounds i32, i32* %5, i32 100
|
2015-02-28 05:17:42 +08:00
|
|
|
%6 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%idx.neg4 = sub i32 0, %6
|
[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
|
|
|
%add.ptr5 = getelementptr inbounds i32, i32* %add.ptr3, i32 %idx.neg4
|
|
|
|
%add.ptr6 = getelementptr inbounds i32, i32* %add.ptr5, i32 -1
|
2013-02-23 20:48:30 +08:00
|
|
|
store i32 %add, i32* %add.ptr6, align 4
|
2013-02-23 00:18:31 +08:00
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %i, align 4
|
2013-02-23 00:18:31 +08:00
|
|
|
%inc = add nsw i32 %7, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%8 = load i32*, i32** @PA, align 4
|
|
|
|
%9 = load i32, i32* %a.addr, align 4
|
[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
|
|
|
%add.ptr7 = getelementptr inbounds i32, i32* %8, i32 %9
|
2015-02-28 05:17:42 +08:00
|
|
|
%10 = load i32, i32* %add.ptr7, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
ret i32 %10
|
|
|
|
}
|
|
|
|
|
|
|
|
; /// Different objects, negative induction, multi-array
|
|
|
|
; int noAlias11 (int a) {
|
|
|
|
; int i, N=10;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
|
|
|
; Bar.A[N][SIZE-i-1] = Bar.B[N][SIZE-i-1] + a;
|
|
|
|
; return Bar.A[N][a];
|
|
|
|
; }
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @noAlias11(
|
2013-11-02 06:18:19 +08:00
|
|
|
; CHECK: store <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-23 20:48:30 +08:00
|
|
|
|
|
|
|
define i32 @noAlias11(i32 %a) #0 {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
%N = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 10, i32* %N, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%sub = sub nsw i32 100, %1
|
|
|
|
%sub1 = sub nsw i32 %sub, 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %N, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 2), i32 0, i32 %2
|
[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
|
|
|
%arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx, i32 0, i32 %sub1
|
2015-02-28 05:17:42 +08:00
|
|
|
%3 = load i32, i32* %arrayidx2, align 4
|
|
|
|
%4 = load i32, i32* %a.addr, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%add = add nsw i32 %3, %4
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%sub3 = sub nsw i32 100, %5
|
|
|
|
%sub4 = sub nsw i32 %sub3, 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%6 = load i32, i32* %N, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx5 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %6
|
[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
|
|
|
%arrayidx6 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx5, i32 0, i32 %sub4
|
2013-02-23 20:48:30 +08:00
|
|
|
store i32 %add, i32* %arrayidx6, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%inc = add nsw i32 %7, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%8 = load i32, i32* %a.addr, align 4
|
|
|
|
%9 = load i32, i32* %N, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx7 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %9
|
[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
|
|
|
%arrayidx8 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx7, i32 0, i32 %8
|
2015-02-28 05:17:42 +08:00
|
|
|
%10 = load i32, i32* %arrayidx8, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
ret i32 %10
|
|
|
|
}
|
|
|
|
|
|
|
|
; /// Same objects, negative induction, multi-array, different sub-elements
|
|
|
|
; int noAlias12 (int a) {
|
|
|
|
; int i, N=10;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
|
|
|
; Bar.A[N][SIZE-i-1] = Bar.A[N+1][SIZE-i-1] + a;
|
|
|
|
; return Bar.A[N][a];
|
|
|
|
; }
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @noAlias12(
|
2013-11-02 06:18:19 +08:00
|
|
|
; CHECK: store <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-23 20:48:30 +08:00
|
|
|
|
|
|
|
define i32 @noAlias12(i32 %a) #0 {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
%N = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 10, i32* %N, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%sub = sub nsw i32 100, %1
|
|
|
|
%sub1 = sub nsw i32 %sub, 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %N, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%add = add nsw i32 %2, 1
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %add
|
[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
|
|
|
%arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx, i32 0, i32 %sub1
|
2015-02-28 05:17:42 +08:00
|
|
|
%3 = load i32, i32* %arrayidx2, align 4
|
|
|
|
%4 = load i32, i32* %a.addr, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%add3 = add nsw i32 %3, %4
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%sub4 = sub nsw i32 100, %5
|
|
|
|
%sub5 = sub nsw i32 %sub4, 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%6 = load i32, i32* %N, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx6 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %6
|
[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
|
|
|
%arrayidx7 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx6, i32 0, i32 %sub5
|
2013-02-23 20:48:30 +08:00
|
|
|
store i32 %add3, i32* %arrayidx7, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%inc = add nsw i32 %7, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%8 = load i32, i32* %a.addr, align 4
|
|
|
|
%9 = load i32, i32* %N, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx8 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %9
|
[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
|
|
|
%arrayidx9 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx8, i32 0, i32 %8
|
2015-02-28 05:17:42 +08:00
|
|
|
%10 = load i32, i32* %arrayidx9, align 4
|
2013-02-23 00:18:31 +08:00
|
|
|
ret i32 %10
|
|
|
|
}
|
|
|
|
|
2013-02-23 20:48:30 +08:00
|
|
|
; /// Same objects, positive induction, constant distance, just enough for vector size
|
|
|
|
; int noAlias13 (int a) {
|
|
|
|
; int i;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
|
|
|
; Foo.A[i] = Foo.A[i+4] + a;
|
|
|
|
; return Foo.A[a];
|
|
|
|
; }
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @noAlias13(
|
2013-02-23 20:48:30 +08:00
|
|
|
; CHECK: add nsw <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-23 20:48:30 +08:00
|
|
|
|
|
|
|
define i32 @noAlias13(i32 %a) #0 {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%add = add nsw i32 %1, 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %add
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %arrayidx, align 4
|
|
|
|
%3 = load i32, i32* %a.addr, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%add1 = add nsw i32 %2, %3
|
2015-02-28 05:17:42 +08:00
|
|
|
%4 = load i32, i32* %i, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %4
|
2013-02-23 20:48:30 +08:00
|
|
|
store i32 %add1, i32* %arrayidx2, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%inc = add nsw i32 %5, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%6 = load i32, i32* %a.addr, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %arrayidx3, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
ret i32 %7
|
|
|
|
}
|
|
|
|
|
|
|
|
; /// Same objects, negative induction, constant distance, just enough for vector size
|
|
|
|
; int noAlias14 (int a) {
|
|
|
|
; int i;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
|
|
|
; Foo.A[SIZE-i-1] = Foo.A[SIZE-i-5] + a;
|
|
|
|
; return Foo.A[a];
|
|
|
|
; }
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define i32 @noAlias14(
|
2016-09-27 01:08:37 +08:00
|
|
|
; CHECK: load <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-23 20:48:30 +08:00
|
|
|
|
|
|
|
define i32 @noAlias14(i32 %a) #0 {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%sub = sub nsw i32 100, %1
|
|
|
|
%sub1 = sub nsw i32 %sub, 5
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %sub1
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %arrayidx, align 4
|
|
|
|
%3 = load i32, i32* %a.addr, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%add = add nsw i32 %2, %3
|
2015-02-28 05:17:42 +08:00
|
|
|
%4 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%sub2 = sub nsw i32 100, %4
|
|
|
|
%sub3 = sub nsw i32 %sub2, 1
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx4 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %sub3
|
2013-02-23 20:48:30 +08:00
|
|
|
store i32 %add, i32* %arrayidx4, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%inc = add nsw i32 %5, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%6 = load i32, i32* %a.addr, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx5 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %arrayidx5, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
ret i32 %7
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:55:32 +08:00
|
|
|
|
|
|
|
;; === Now, the tests that we could vectorize with induction changes or run-time checks ===
|
|
|
|
|
|
|
|
|
|
|
|
; /// Different objects, swapped induction, alias at the end
|
|
|
|
; int mayAlias01 (int a) {
|
2013-02-23 20:48:30 +08:00
|
|
|
; int i;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
|
|
|
; Foo.A[i] = Foo.B[SIZE-i-1] + a;
|
|
|
|
; return Foo.A[a];
|
|
|
|
; }
|
2016-06-02 02:55:32 +08:00
|
|
|
; CHECK-LABEL: define i32 @mayAlias01(
|
|
|
|
; CHECK-NOT: add nsw <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-23 20:48:30 +08:00
|
|
|
|
2016-06-02 02:55:32 +08:00
|
|
|
define i32 @mayAlias01(i32 %a) nounwind {
|
2013-02-23 20:48:30 +08:00
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%sub = sub nsw i32 100, %1
|
|
|
|
%sub1 = sub nsw i32 %sub, 1
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %sub1
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %arrayidx, align 4
|
|
|
|
%3 = load i32, i32* %a.addr, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%add = add nsw i32 %2, %3
|
2015-02-28 05:17:42 +08:00
|
|
|
%4 = load i32, i32* %i, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %4
|
2013-02-23 20:48:30 +08:00
|
|
|
store i32 %add, i32* %arrayidx2, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %i, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
%inc = add nsw i32 %5, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%6 = load i32, i32* %a.addr, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %arrayidx3, align 4
|
2013-02-23 20:48:30 +08:00
|
|
|
ret i32 %7
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:55:32 +08:00
|
|
|
; /// Different objects, swapped induction, alias at the beginning
|
|
|
|
; int mayAlias02 (int a) {
|
2013-02-22 06:39:03 +08:00
|
|
|
; int i;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
|
|
|
; Foo.A[SIZE-i-1] = Foo.B[i] + a;
|
|
|
|
; return Foo.A[a];
|
|
|
|
; }
|
2016-06-02 02:55:32 +08:00
|
|
|
; CHECK-LABEL: define i32 @mayAlias02(
|
|
|
|
; CHECK-NOT: add nsw <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-22 06:39:03 +08:00
|
|
|
|
2016-06-02 02:55:32 +08:00
|
|
|
define i32 @mayAlias02(i32 %a) nounwind {
|
2013-02-22 06:39:03 +08:00
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %i, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %1
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %arrayidx, align 4
|
|
|
|
%3 = load i32, i32* %a.addr, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%add = add nsw i32 %2, %3
|
2015-02-28 05:17:42 +08:00
|
|
|
%4 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%sub = sub nsw i32 100, %4
|
|
|
|
%sub1 = sub nsw i32 %sub, 1
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %sub1
|
2013-02-22 06:39:03 +08:00
|
|
|
store i32 %add, i32* %arrayidx2, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%inc = add nsw i32 %5, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%6 = load i32, i32* %a.addr, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %arrayidx3, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
ret i32 %7
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:55:32 +08:00
|
|
|
; /// Pointer access, run-time check added
|
|
|
|
; int mayAlias03 (int a) {
|
|
|
|
; int i;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
|
|
|
; *(PA+i) = *(PB+SIZE-i-1) + a;
|
|
|
|
; return *(PA+a);
|
|
|
|
; }
|
|
|
|
; CHECK-LABEL: define i32 @mayAlias03(
|
|
|
|
; CHECK-NOT: add nsw <4 x i32>
|
|
|
|
; CHECK: ret
|
|
|
|
|
|
|
|
define i32 @mayAlias03(i32 %a) nounwind {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
|
|
|
%0 = load i32, i32* %i, align 4
|
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
|
|
|
%1 = load i32*, i32** @PB, align 4
|
|
|
|
%add.ptr = getelementptr inbounds i32, i32* %1, i32 100
|
|
|
|
%2 = load i32, i32* %i, align 4
|
|
|
|
%idx.neg = sub i32 0, %2
|
|
|
|
%add.ptr1 = getelementptr inbounds i32, i32* %add.ptr, i32 %idx.neg
|
|
|
|
%add.ptr2 = getelementptr inbounds i32, i32* %add.ptr1, i32 -1
|
|
|
|
%3 = load i32, i32* %add.ptr2, align 4
|
|
|
|
%4 = load i32, i32* %a.addr, align 4
|
|
|
|
%add = add nsw i32 %3, %4
|
|
|
|
%5 = load i32*, i32** @PA, align 4
|
|
|
|
%6 = load i32, i32* %i, align 4
|
|
|
|
%add.ptr3 = getelementptr inbounds i32, i32* %5, i32 %6
|
|
|
|
store i32 %add, i32* %add.ptr3, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
|
|
|
%7 = load i32, i32* %i, align 4
|
|
|
|
%inc = add nsw i32 %7, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
|
|
|
%8 = load i32*, i32** @PA, align 4
|
|
|
|
%9 = load i32, i32* %a.addr, align 4
|
|
|
|
%add.ptr4 = getelementptr inbounds i32, i32* %8, i32 %9
|
|
|
|
%10 = load i32, i32* %add.ptr4, align 4
|
|
|
|
ret i32 %10
|
|
|
|
}
|
|
|
|
|
2013-02-23 20:48:30 +08:00
|
|
|
|
2016-06-02 02:55:32 +08:00
|
|
|
;; === Finally, the tests that should only vectorize with care (or if we ignore undefined behaviour at all) ===
|
2013-02-23 20:48:30 +08:00
|
|
|
|
|
|
|
|
2016-06-02 02:55:32 +08:00
|
|
|
; int mustAlias01 (int a) {
|
2013-02-22 06:39:03 +08:00
|
|
|
; int i;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
|
|
|
; Foo.A[i+10] = Foo.B[SIZE-i-1] + a;
|
|
|
|
; return Foo.A[a];
|
|
|
|
; }
|
2016-06-02 02:55:32 +08:00
|
|
|
; CHECK-LABEL: define i32 @mustAlias01(
|
|
|
|
; CHECK-NOT: add nsw <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-22 06:39:03 +08:00
|
|
|
|
2016-06-02 02:55:32 +08:00
|
|
|
define i32 @mustAlias01(i32 %a) nounwind {
|
2013-02-22 06:39:03 +08:00
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%sub = sub nsw i32 100, %1
|
|
|
|
%sub1 = sub nsw i32 %sub, 1
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %sub1
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %arrayidx, align 4
|
|
|
|
%3 = load i32, i32* %a.addr, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%add = add nsw i32 %2, %3
|
2015-02-28 05:17:42 +08:00
|
|
|
%4 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%add2 = add nsw i32 %4, 10
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %add2
|
2013-02-22 06:39:03 +08:00
|
|
|
store i32 %add, i32* %arrayidx3, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%inc = add nsw i32 %5, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%6 = load i32, i32* %a.addr, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx4 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %arrayidx4, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
ret i32 %7
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:55:32 +08:00
|
|
|
; int mustAlias02 (int a) {
|
2013-02-22 06:39:03 +08:00
|
|
|
; int i;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
|
|
|
; Foo.A[i] = Foo.B[SIZE-i-10] + a;
|
|
|
|
; return Foo.A[a];
|
|
|
|
; }
|
2016-06-02 02:55:32 +08:00
|
|
|
; CHECK-LABEL: define i32 @mustAlias02(
|
|
|
|
; CHECK-NOT: add nsw <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-22 06:39:03 +08:00
|
|
|
|
2016-06-02 02:55:32 +08:00
|
|
|
define i32 @mustAlias02(i32 %a) nounwind {
|
2013-02-22 06:39:03 +08:00
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%sub = sub nsw i32 100, %1
|
|
|
|
%sub1 = sub nsw i32 %sub, 10
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %sub1
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %arrayidx, align 4
|
|
|
|
%3 = load i32, i32* %a.addr, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%add = add nsw i32 %2, %3
|
2015-02-28 05:17:42 +08:00
|
|
|
%4 = load i32, i32* %i, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %4
|
2013-02-22 06:39:03 +08:00
|
|
|
store i32 %add, i32* %arrayidx2, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%inc = add nsw i32 %5, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%6 = load i32, i32* %a.addr, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %arrayidx3, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
ret i32 %7
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:55:32 +08:00
|
|
|
; int mustAlias03 (int a) {
|
2013-02-22 06:39:03 +08:00
|
|
|
; int i;
|
|
|
|
; for (i=0; i<SIZE; i++)
|
|
|
|
; Foo.A[i+10] = Foo.B[SIZE-i-10] + a;
|
|
|
|
; return Foo.A[a];
|
|
|
|
; }
|
2016-06-02 02:55:32 +08:00
|
|
|
; CHECK-LABEL: define i32 @mustAlias03(
|
|
|
|
; CHECK-NOT: add nsw <4 x i32>
|
2013-03-10 02:25:40 +08:00
|
|
|
; CHECK: ret
|
2013-02-22 06:39:03 +08:00
|
|
|
|
2016-06-02 02:55:32 +08:00
|
|
|
define i32 @mustAlias03(i32 %a) nounwind {
|
2013-02-22 06:39:03 +08:00
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%i = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 0, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %for.inc, %entry
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%cmp = icmp slt i32 %0, 100
|
|
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%sub = sub nsw i32 100, %1
|
|
|
|
%sub1 = sub nsw i32 %sub, 10
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %sub1
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %arrayidx, align 4
|
|
|
|
%3 = load i32, i32* %a.addr, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%add = add nsw i32 %2, %3
|
2015-02-28 05:17:42 +08:00
|
|
|
%4 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%add2 = add nsw i32 %4, 10
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %add2
|
2013-02-22 06:39:03 +08:00
|
|
|
store i32 %add, i32* %arrayidx3, align 4
|
|
|
|
br label %for.inc
|
|
|
|
|
|
|
|
for.inc: ; preds = %for.body
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %i, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
%inc = add nsw i32 %5, 1
|
|
|
|
store i32 %inc, i32* %i, align 4
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond
|
2015-02-28 05:17:42 +08:00
|
|
|
%6 = load i32, i32* %a.addr, align 4
|
2015-03-14 02:20:45 +08:00
|
|
|
%arrayidx4 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load i32, i32* %arrayidx4, align 4
|
2013-02-22 06:39:03 +08:00
|
|
|
ret i32 %7
|
|
|
|
}
|