2013-08-22 03:53:10 +08:00
|
|
|
target datalayout = "e-p:64:64:64-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
|
2009-11-04 16:05:20 +08:00
|
|
|
|
|
|
|
; Optimize subtracts.
|
2002-05-06 13:51:26 +08:00
|
|
|
;
|
2009-11-04 15:57:05 +08:00
|
|
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
2002-05-06 13:51:26 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test1(i32 %A) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%B = sub i32 %A, %A
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %B
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test1(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: ret i32 0
|
2002-05-06 13:51:26 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test2(i32 %A) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%B = sub i32 %A, 0
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %B
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test2(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: ret i32 %A
|
2002-05-06 13:51:26 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test3(i32 %A) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%B = sub i32 0, %A
|
|
|
|
%C = sub i32 0, %B
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %C
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test3(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: ret i32 %A
|
2002-05-07 00:19:16 +08:00
|
|
|
}
|
2002-05-09 07:15:01 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test4(i32 %A, i32 %x) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%B = sub i32 0, %A
|
|
|
|
%C = sub i32 %x, %B
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %C
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test4(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: %C = add i32 %x, %A
|
|
|
|
; CHECK: ret i32 %C
|
2002-05-09 07:15:01 +08:00
|
|
|
}
|
|
|
|
|
2009-11-04 15:57:05 +08:00
|
|
|
define i32 @test5(i32 %A, i32 %B, i32 %C) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%D = sub i32 %B, %C
|
|
|
|
%E = sub i32 %A, %D
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %E
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test5(
|
2011-02-10 13:17:27 +08:00
|
|
|
; CHECK: %D1 = sub i32 %C, %B
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: %E = add
|
|
|
|
; CHECK: ret i32 %E
|
2002-05-09 07:15:01 +08:00
|
|
|
}
|
2003-02-19 03:28:47 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test6(i32 %A, i32 %B) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%C = and i32 %A, %B
|
|
|
|
%D = sub i32 %A, %C
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %D
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test6(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK-NEXT: xor i32 %B, -1
|
2013-08-22 03:53:10 +08:00
|
|
|
; CHECK-NEXT: %D = and i32
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK-NEXT: ret i32 %D
|
2003-02-19 03:28:47 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test7(i32 %A) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%B = sub i32 -1, %A
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %B
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test7(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: %B = xor i32 %A, -1
|
|
|
|
; CHECK: ret i32 %B
|
2003-02-19 03:28:47 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test8(i32 %A) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%B = mul i32 9, %A
|
|
|
|
%C = sub i32 %B, %A
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %C
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test8(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: %C = shl i32 %A, 3
|
|
|
|
; CHECK: ret i32 %C
|
2003-02-19 03:55:31 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test9(i32 %A) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%B = mul i32 3, %A
|
|
|
|
%C = sub i32 %A, %B
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %C
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test9(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: %C = mul i32 %A, -2
|
|
|
|
; CHECK: ret i32 %C
|
2003-02-19 03:55:31 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test10(i32 %A, i32 %B) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%C = sub i32 0, %A
|
|
|
|
%D = sub i32 0, %B
|
|
|
|
%E = mul i32 %C, %D
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %E
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test10(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: %E = mul i32 %A, %B
|
|
|
|
; CHECK: ret i32 %E
|
2003-03-11 07:22:50 +08:00
|
|
|
}
|
|
|
|
|
2009-11-04 15:57:05 +08:00
|
|
|
define i32 @test10a(i32 %A) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%C = sub i32 0, %A
|
|
|
|
%E = mul i32 %C, 7
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %E
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test10a(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: %E = mul i32 %A, -7
|
|
|
|
; CHECK: ret i32 %E
|
2003-03-11 07:22:50 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i1 @test11(i8 %A, i8 %B) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%C = sub i8 %A, %B
|
|
|
|
%cD = icmp ne i8 %C, 0
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i1 %cD
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test11(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: %cD = icmp ne i8 %A, %B
|
|
|
|
; CHECK: ret i1 %cD
|
2003-08-13 13:27:57 +08:00
|
|
|
}
|
2004-03-13 07:52:51 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test12(i32 %A) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%B = ashr i32 %A, 31
|
|
|
|
%C = sub i32 0, %B
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %C
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test12(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: %C = lshr i32 %A, 31
|
|
|
|
; CHECK: ret i32 %C
|
2004-03-13 07:52:51 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test13(i32 %A) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%B = lshr i32 %A, 31
|
|
|
|
%C = sub i32 0, %B
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %C
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test13(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: %C = ashr i32 %A, 31
|
|
|
|
; CHECK: ret i32 %C
|
2004-03-13 07:52:51 +08:00
|
|
|
}
|
2004-03-13 08:11:38 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test14(i32 %A) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%B = lshr i32 %A, 31
|
|
|
|
%C = bitcast i32 %B to i32
|
|
|
|
%D = sub i32 0, %C
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %D
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test14(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: %D = ashr i32 %A, 31
|
|
|
|
; CHECK: ret i32 %D
|
2004-03-13 08:11:38 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test15(i32 %A, i32 %B) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%C = sub i32 0, %A
|
|
|
|
%D = srem i32 %B, %C
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %D
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test15(
|
2014-10-14 06:37:51 +08:00
|
|
|
; CHECK: %[[sub:.*]] = sub i32 0, %A
|
|
|
|
; CHECK-NEXT: %[[rem:.*]] = srem i32 %B, %[[sub]]
|
|
|
|
; CHECK: ret i32 %[[rem]]
|
2004-07-06 15:00:11 +08:00
|
|
|
}
|
2004-10-06 23:07:56 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test16(i32 %A) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%X = sdiv i32 %A, 1123
|
|
|
|
%Y = sub i32 0, %X
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %Y
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test16(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: %Y = sdiv i32 %A, -1123
|
|
|
|
; CHECK: ret i32 %Y
|
2004-10-06 23:07:56 +08:00
|
|
|
}
|
2004-10-09 10:50:01 +08:00
|
|
|
|
2008-11-30 11:42:12 +08:00
|
|
|
; Can't fold subtract here because negation it might oveflow.
|
|
|
|
; PR3142
|
2009-11-04 15:57:05 +08:00
|
|
|
define i32 @test17(i32 %A) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%B = sub i32 0, %A
|
|
|
|
%C = sdiv i32 %B, 1234
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %C
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test17(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: %B = sub i32 0, %A
|
|
|
|
; CHECK: %C = sdiv i32 %B, 1234
|
|
|
|
; CHECK: ret i32 %C
|
2004-10-09 10:50:01 +08:00
|
|
|
}
|
2004-11-14 03:49:39 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i64 @test18(i64 %Y) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%tmp.4 = shl i64 %Y, 2
|
|
|
|
%tmp.12 = shl i64 %Y, 2
|
|
|
|
%tmp.8 = sub i64 %tmp.4, %tmp.12
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i64 %tmp.8
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test18(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: ret i64 0
|
2004-11-14 03:49:39 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test19(i32 %X, i32 %Y) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%Z = sub i32 %X, %Y
|
|
|
|
%Q = add i32 %Z, %Y
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %Q
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test19(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: ret i32 %X
|
2005-04-08 00:41:45 +08:00
|
|
|
}
|
2006-02-27 09:43:02 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i1 @test20(i32 %g, i32 %h) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%tmp.2 = sub i32 %g, %h
|
|
|
|
%tmp.4 = icmp ne i32 %tmp.2, %g
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i1 %tmp.4
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test20(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: %tmp.4 = icmp ne i32 %h, 0
|
|
|
|
; CHECK: ret i1 %tmp.4
|
2006-02-27 09:43:02 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i1 @test21(i32 %g, i32 %h) {
|
2013-08-22 03:53:10 +08:00
|
|
|
%tmp.2 = sub i32 %g, %h
|
|
|
|
%tmp.4 = icmp ne i32 %tmp.2, %g
|
2009-11-04 15:57:05 +08:00
|
|
|
ret i1 %tmp.4
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test21(
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: %tmp.4 = icmp ne i32 %h, 0
|
|
|
|
; CHECK: ret i1 %tmp.4
|
2006-02-27 09:43:02 +08:00
|
|
|
}
|
2008-05-09 13:19:28 +08:00
|
|
|
|
|
|
|
; PR2298
|
2011-06-17 11:14:27 +08:00
|
|
|
define zeroext i1 @test22(i32 %a, i32 %b) nounwind {
|
2013-08-22 03:53:10 +08:00
|
|
|
%tmp2 = sub i32 0, %a
|
|
|
|
%tmp4 = sub i32 0, %b
|
|
|
|
%tmp5 = icmp eq i32 %tmp2, %tmp4
|
2009-11-04 15:57:05 +08:00
|
|
|
ret i1 %tmp5
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test22(
|
2011-02-19 00:25:37 +08:00
|
|
|
; CHECK: %tmp5 = icmp eq i32 %b, %a
|
2009-11-04 15:57:05 +08:00
|
|
|
; CHECK: ret i1 %tmp5
|
2008-05-09 13:19:28 +08:00
|
|
|
}
|
|
|
|
|
2009-11-04 16:05:20 +08:00
|
|
|
; rdar://7362831
|
|
|
|
define i32 @test23(i8* %P, i64 %A){
|
[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
|
|
|
%B = getelementptr inbounds i8, i8* %P, i64 %A
|
2009-11-04 16:05:20 +08:00
|
|
|
%C = ptrtoint i8* %B to i64
|
|
|
|
%D = trunc i64 %C to i32
|
|
|
|
%E = ptrtoint i8* %P to i64
|
|
|
|
%F = trunc i64 %E to i32
|
|
|
|
%G = sub i32 %D, %F
|
|
|
|
ret i32 %G
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test23(
|
2010-01-06 05:16:30 +08:00
|
|
|
; CHECK-NEXT: = trunc i64 %A to i32
|
|
|
|
; CHECK-NEXT: ret i32
|
2009-11-04 16:05:20 +08:00
|
|
|
}
|
|
|
|
|
2013-08-22 03:53:10 +08:00
|
|
|
define i8 @test23_as1(i8 addrspace(1)* %P, i16 %A) {
|
|
|
|
; CHECK: @test23_as1
|
|
|
|
; CHECK-NEXT: = trunc i16 %A to i8
|
|
|
|
; CHECK-NEXT: ret i8
|
[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
|
|
|
%B = getelementptr inbounds i8, i8 addrspace(1)* %P, i16 %A
|
2013-08-22 03:53:10 +08:00
|
|
|
%C = ptrtoint i8 addrspace(1)* %B to i16
|
|
|
|
%D = trunc i16 %C to i8
|
|
|
|
%E = ptrtoint i8 addrspace(1)* %P to i16
|
|
|
|
%F = trunc i16 %E to i8
|
|
|
|
%G = sub i8 %D, %F
|
|
|
|
ret i8 %G
|
|
|
|
}
|
|
|
|
|
2009-11-04 16:05:20 +08:00
|
|
|
define i64 @test24(i8* %P, i64 %A){
|
[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
|
|
|
%B = getelementptr inbounds i8, i8* %P, i64 %A
|
2009-11-04 16:05:20 +08:00
|
|
|
%C = ptrtoint i8* %B to i64
|
|
|
|
%E = ptrtoint i8* %P to i64
|
|
|
|
%G = sub i64 %C, %E
|
|
|
|
ret i64 %G
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test24(
|
2009-11-04 16:05:20 +08:00
|
|
|
; CHECK-NEXT: ret i64 %A
|
|
|
|
}
|
|
|
|
|
2013-08-22 03:53:10 +08:00
|
|
|
define i16 @test24_as1(i8 addrspace(1)* %P, i16 %A) {
|
|
|
|
; CHECK: @test24_as1
|
|
|
|
; CHECK-NEXT: ret i16 %A
|
[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
|
|
|
%B = getelementptr inbounds i8, i8 addrspace(1)* %P, i16 %A
|
2013-08-22 03:53:10 +08:00
|
|
|
%C = ptrtoint i8 addrspace(1)* %B to i16
|
|
|
|
%E = ptrtoint i8 addrspace(1)* %P to i16
|
|
|
|
%G = sub i16 %C, %E
|
|
|
|
ret i16 %G
|
|
|
|
}
|
|
|
|
|
2009-11-04 16:05:20 +08:00
|
|
|
define i64 @test24a(i8* %P, i64 %A){
|
[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
|
|
|
%B = getelementptr inbounds i8, i8* %P, i64 %A
|
2009-11-04 16:05:20 +08:00
|
|
|
%C = ptrtoint i8* %B to i64
|
|
|
|
%E = ptrtoint i8* %P to i64
|
|
|
|
%G = sub i64 %E, %C
|
|
|
|
ret i64 %G
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test24a(
|
2009-11-04 16:05:20 +08:00
|
|
|
; CHECK-NEXT: sub i64 0, %A
|
2013-08-22 03:53:10 +08:00
|
|
|
; CHECK-NEXT: ret i64
|
2009-11-04 16:05:20 +08:00
|
|
|
}
|
|
|
|
|
2013-08-22 03:53:10 +08:00
|
|
|
define i16 @test24a_as1(i8 addrspace(1)* %P, i16 %A) {
|
|
|
|
; CHECK: @test24a_as1
|
|
|
|
; CHECK-NEXT: sub i16 0, %A
|
|
|
|
; CHECK-NEXT: ret i16
|
[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
|
|
|
%B = getelementptr inbounds i8, i8 addrspace(1)* %P, i16 %A
|
2013-08-22 03:53:10 +08:00
|
|
|
%C = ptrtoint i8 addrspace(1)* %B to i16
|
|
|
|
%E = ptrtoint i8 addrspace(1)* %P to i16
|
|
|
|
%G = sub i16 %E, %C
|
|
|
|
ret i16 %G
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-02 06:29:12 +08:00
|
|
|
@Arr = external global [42 x i16]
|
|
|
|
|
|
|
|
define i64 @test24b(i8* %P, i64 %A){
|
[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
|
|
|
%B = getelementptr inbounds [42 x i16], [42 x i16]* @Arr, i64 0, i64 %A
|
2010-01-02 06:29:12 +08:00
|
|
|
%C = ptrtoint i16* %B to i64
|
|
|
|
%G = sub i64 %C, ptrtoint ([42 x i16]* @Arr to i64)
|
|
|
|
ret i64 %G
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test24b(
|
2011-02-10 15:11:16 +08:00
|
|
|
; CHECK-NEXT: shl nuw i64 %A, 1
|
2013-08-22 03:53:10 +08:00
|
|
|
; CHECK-NEXT: ret i64
|
2010-01-02 06:29:12 +08:00
|
|
|
}
|
|
|
|
|
2010-01-02 06:42:29 +08:00
|
|
|
|
|
|
|
define i64 @test25(i8* %P, i64 %A){
|
[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
|
|
|
%B = getelementptr inbounds [42 x i16], [42 x i16]* @Arr, i64 0, i64 %A
|
2010-01-02 06:42:29 +08:00
|
|
|
%C = ptrtoint i16* %B to i64
|
2015-03-14 02:20:45 +08:00
|
|
|
%G = sub i64 %C, ptrtoint (i16* getelementptr ([42 x i16], [42 x i16]* @Arr, i64 1, i64 0) to i64)
|
2010-01-02 06:42:29 +08:00
|
|
|
ret i64 %G
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test25(
|
2011-02-10 15:11:16 +08:00
|
|
|
; CHECK-NEXT: shl nuw i64 %A, 1
|
2010-01-02 06:42:29 +08:00
|
|
|
; CHECK-NEXT: add i64 {{.*}}, -84
|
2013-08-22 03:53:10 +08:00
|
|
|
; CHECK-NEXT: ret i64
|
|
|
|
}
|
|
|
|
|
|
|
|
@Arr_as1 = external addrspace(1) global [42 x i16]
|
|
|
|
|
|
|
|
define i16 @test25_as1(i8 addrspace(1)* %P, i64 %A) {
|
|
|
|
; CHECK: @test25_as1
|
|
|
|
; CHECK-NEXT: %1 = trunc i64 %A to i16
|
|
|
|
; CHECK-NEXT: shl nuw i16 %1, 1
|
|
|
|
; CHECK-NEXT: add i16 {{.*}}, -84
|
|
|
|
; CHECK-NEXT: ret i16
|
[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
|
|
|
%B = getelementptr inbounds [42 x i16], [42 x i16] addrspace(1)* @Arr_as1, i64 0, i64 %A
|
2013-08-22 03:53:10 +08:00
|
|
|
%C = ptrtoint i16 addrspace(1)* %B to i16
|
2015-03-14 02:20:45 +08:00
|
|
|
%G = sub i16 %C, ptrtoint (i16 addrspace(1)* getelementptr ([42 x i16], [42 x i16] addrspace(1)* @Arr_as1, i64 1, i64 0) to i16)
|
2013-08-22 03:53:10 +08:00
|
|
|
ret i16 %G
|
2010-01-02 06:42:29 +08:00
|
|
|
}
|
|
|
|
|
2010-01-31 10:30:23 +08:00
|
|
|
define i32 @test26(i32 %x) {
|
|
|
|
%shl = shl i32 3, %x
|
|
|
|
%neg = sub i32 0, %shl
|
|
|
|
ret i32 %neg
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test26(
|
2010-01-31 10:30:23 +08:00
|
|
|
; CHECK-NEXT: shl i32 -3
|
|
|
|
; CHECK-NEXT: ret i32
|
|
|
|
}
|
2010-01-02 06:42:29 +08:00
|
|
|
|
2010-11-23 04:31:27 +08:00
|
|
|
define i32 @test27(i32 %x, i32 %y) {
|
|
|
|
%mul = mul i32 %y, -8
|
|
|
|
%sub = sub i32 %x, %mul
|
|
|
|
ret i32 %sub
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test27(
|
2010-11-23 04:31:27 +08:00
|
|
|
; CHECK-NEXT: shl i32 %y, 3
|
|
|
|
; CHECK-NEXT: add i32
|
|
|
|
; CHECK-NEXT: ret i32
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test28(i32 %x, i32 %y, i32 %z) {
|
|
|
|
%neg = sub i32 0, %z
|
|
|
|
%mul = mul i32 %neg, %y
|
|
|
|
%sub = sub i32 %x, %mul
|
|
|
|
ret i32 %sub
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test28(
|
2010-11-23 04:31:27 +08:00
|
|
|
; CHECK-NEXT: mul i32 %z, %y
|
|
|
|
; CHECK-NEXT: add i32
|
|
|
|
; CHECK-NEXT: ret i32
|
|
|
|
}
|
2012-02-20 22:34:57 +08:00
|
|
|
|
|
|
|
define i64 @test29(i8* %foo, i64 %i, i64 %j) {
|
[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
|
|
|
%gep1 = getelementptr inbounds i8, i8* %foo, i64 %i
|
|
|
|
%gep2 = getelementptr inbounds i8, i8* %foo, i64 %j
|
2012-02-20 22:34:57 +08:00
|
|
|
%cast1 = ptrtoint i8* %gep1 to i64
|
|
|
|
%cast2 = ptrtoint i8* %gep2 to i64
|
|
|
|
%sub = sub i64 %cast1, %cast2
|
|
|
|
ret i64 %sub
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test29(
|
2012-02-20 22:34:57 +08:00
|
|
|
; CHECK-NEXT: sub i64 %i, %j
|
|
|
|
; CHECK-NEXT: ret i64
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test30(i8* %foo, i64 %i, i64 %j) {
|
|
|
|
%bit = bitcast i8* %foo to i32*
|
[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
|
|
|
%gep1 = getelementptr inbounds i32, i32* %bit, i64 %i
|
|
|
|
%gep2 = getelementptr inbounds i8, i8* %foo, i64 %j
|
2012-02-20 22:34:57 +08:00
|
|
|
%cast1 = ptrtoint i32* %gep1 to i64
|
|
|
|
%cast2 = ptrtoint i8* %gep2 to i64
|
|
|
|
%sub = sub i64 %cast1, %cast2
|
|
|
|
ret i64 %sub
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test30(
|
2012-02-20 22:34:57 +08:00
|
|
|
; CHECK-NEXT: %gep1.idx = shl nuw i64 %i, 2
|
|
|
|
; CHECK-NEXT: sub i64 %gep1.idx, %j
|
|
|
|
; CHECK-NEXT: ret i64
|
|
|
|
}
|
2013-08-22 03:53:10 +08:00
|
|
|
|
|
|
|
define i16 @test30_as1(i8 addrspace(1)* %foo, i16 %i, i16 %j) {
|
|
|
|
; CHECK-LABEL: @test30_as1(
|
|
|
|
; CHECK-NEXT: %gep1.idx = shl nuw i16 %i, 2
|
|
|
|
; CHECK-NEXT: sub i16 %gep1.idx, %j
|
|
|
|
; CHECK-NEXT: ret i16
|
|
|
|
%bit = bitcast i8 addrspace(1)* %foo to i32 addrspace(1)*
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
llvm-svn: 230786
2015-02-28 03:29:02 +08:00
|
|
|
%gep1 = getelementptr inbounds i32, i32 addrspace(1)* %bit, i16 %i
|
|
|
|
%gep2 = getelementptr inbounds i8, i8 addrspace(1)* %foo, i16 %j
|
2013-08-22 03:53:10 +08:00
|
|
|
%cast1 = ptrtoint i32 addrspace(1)* %gep1 to i16
|
|
|
|
%cast2 = ptrtoint i8 addrspace(1)* %gep2 to i16
|
|
|
|
%sub = sub i16 %cast1, %cast2
|
|
|
|
ret i16 %sub
|
|
|
|
}
|
|
|
|
|
2014-01-19 23:24:22 +08:00
|
|
|
define <2 x i64> @test31(<2 x i64> %A) {
|
|
|
|
%xor = xor <2 x i64> %A, <i64 -1, i64 -1>
|
|
|
|
%sub = sub <2 x i64> <i64 2, i64 3>, %xor
|
|
|
|
ret <2 x i64> %sub
|
|
|
|
; CHECK-LABEL: @test31(
|
|
|
|
; CHECK-NEXT: %sub = add <2 x i64> %A, <i64 3, i64 4>
|
|
|
|
; CHECK-NEXT: ret <2 x i64> %sub
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x i64> @test32(<2 x i64> %A) {
|
|
|
|
%add = add <2 x i64> %A, <i64 -1, i64 -1>
|
|
|
|
%sub = sub <2 x i64> <i64 2, i64 3>, %add
|
|
|
|
ret <2 x i64> %sub
|
|
|
|
; CHECK-LABEL: @test32(
|
|
|
|
; CHECK-NEXT: %sub = sub <2 x i64> <i64 3, i64 4>
|
|
|
|
; CHECK-NEXT: ret <2 x i64> %sub
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x i64> @test33(<2 x i1> %A) {
|
|
|
|
%ext = zext <2 x i1> %A to <2 x i64>
|
|
|
|
%sub = sub <2 x i64> zeroinitializer, %ext
|
|
|
|
ret <2 x i64> %sub
|
|
|
|
; CHECK-LABEL: @test33(
|
|
|
|
; CHECK-NEXT: %sub = sext <2 x i1> %A to <2 x i64>
|
|
|
|
; CHECK-NEXT: ret <2 x i64> %sub
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x i64> @test34(<2 x i1> %A) {
|
|
|
|
%ext = sext <2 x i1> %A to <2 x i64>
|
|
|
|
%sub = sub <2 x i64> zeroinitializer, %ext
|
|
|
|
ret <2 x i64> %sub
|
|
|
|
; CHECK-LABEL: @test34(
|
|
|
|
; CHECK-NEXT: %sub = zext <2 x i1> %A to <2 x i64>
|
|
|
|
; CHECK-NEXT: ret <2 x i64> %sub
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x i64> @test35(<2 x i64> %A) {
|
|
|
|
%mul = mul <2 x i64> %A, <i64 3, i64 4>
|
|
|
|
%sub = sub <2 x i64> %A, %mul
|
|
|
|
ret <2 x i64> %sub
|
|
|
|
; CHECK-LABEL: @test35(
|
|
|
|
; CHECK-NEXT: %sub = mul <2 x i64> %A, <i64 -2, i64 -3>
|
|
|
|
; CHECK-NEXT: ret <2 x i64> %sub
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x i64> @test36(<2 x i64> %A) {
|
|
|
|
%shl = shl <2 x i64> %A, <i64 3, i64 4>
|
|
|
|
%sub = sub <2 x i64> %shl, %A
|
|
|
|
ret <2 x i64> %sub
|
|
|
|
; CHECK-LABEL: @test36(
|
|
|
|
; CHECK-NEXT: %sub = mul <2 x i64> %A, <i64 7, i64 15>
|
|
|
|
; CHECK-NEXT: ret <2 x i64> %sub
|
|
|
|
}
|
2014-07-02 14:07:09 +08:00
|
|
|
|
2014-07-02 14:14:13 +08:00
|
|
|
define <2 x i32> @test37(<2 x i32> %A) {
|
|
|
|
%div = sdiv <2 x i32> %A, <i32 -2147483648, i32 -2147483648>
|
|
|
|
%sub = sub nsw <2 x i32> zeroinitializer, %div
|
|
|
|
ret <2 x i32> %sub
|
2014-07-02 14:07:09 +08:00
|
|
|
; CHECK-LABEL: @test37(
|
2014-07-02 14:42:13 +08:00
|
|
|
; CHECK-NEXT: [[ICMP:%.*]] = icmp eq <2 x i32> %A, <i32 -2147483648, i32 -2147483648>
|
|
|
|
; CHECK-NEXT: [[SEXT:%.*]] = sext <2 x i1> [[ICMP]] to <2 x i32>
|
|
|
|
; CHECK-NEXT: ret <2 x i32> [[SEXT]]
|
2014-07-02 14:07:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test38(i32 %A) {
|
|
|
|
%div = sdiv i32 %A, -2147483648
|
|
|
|
%sub = sub nsw i32 0, %div
|
|
|
|
ret i32 %sub
|
|
|
|
; CHECK-LABEL: @test38(
|
2014-07-02 14:42:13 +08:00
|
|
|
; CHECK-NEXT: [[ICMP:%.*]] = icmp eq i32 %A, -2147483648
|
|
|
|
; CHECK-NEXT: [[SEXT:%.*]] = sext i1 [[ICMP]] to i32
|
|
|
|
; CHECK-NEXT: ret i32 [[SEXT]]
|
2014-07-02 14:07:09 +08:00
|
|
|
}
|
2014-07-31 12:49:29 +08:00
|
|
|
|
|
|
|
define i32 @test39(i32 %A, i32 %x) {
|
|
|
|
%B = sub i32 0, %A
|
|
|
|
%C = sub nsw i32 %x, %B
|
|
|
|
ret i32 %C
|
|
|
|
; CHECK-LABEL: @test39(
|
|
|
|
; CHECK: %C = add i32 %x, %A
|
|
|
|
; CHECK: ret i32 %C
|
|
|
|
}
|
2014-08-20 07:36:30 +08:00
|
|
|
|
|
|
|
define i16 @test40(i16 %a, i16 %b) {
|
|
|
|
%ashr = ashr i16 %a, 1
|
|
|
|
%ashr1 = ashr i16 %b, 1
|
|
|
|
%sub = sub i16 %ashr, %ashr1
|
|
|
|
ret i16 %sub
|
|
|
|
; CHECK-LABEL: @test40(
|
|
|
|
; CHECK-NEXT: [[ASHR:%.*]] = ashr i16 %a, 1
|
|
|
|
; CHECK-NEXT: [[ASHR1:%.*]] = ashr i16 %b, 1
|
|
|
|
; CHECK-NEXT: [[RET:%.*]] = sub nsw i16 [[ASHR]], [[ASHR1]]
|
|
|
|
; CHECK: ret i16 [[RET]]
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test41(i16 %a, i16 %b) {
|
|
|
|
%conv = sext i16 %a to i32
|
|
|
|
%conv1 = sext i16 %b to i32
|
|
|
|
%sub = sub i32 %conv, %conv1
|
|
|
|
ret i32 %sub
|
|
|
|
; CHECK-LABEL: @test41(
|
|
|
|
; CHECK-NEXT: [[SEXT:%.*]] = sext i16 %a to i32
|
|
|
|
; CHECK-NEXT: [[SEXT1:%.*]] = sext i16 %b to i32
|
|
|
|
; CHECK-NEXT: [[RET:%.*]] = sub nsw i32 [[SEXT]], [[SEXT1]]
|
|
|
|
; CHECK: ret i32 [[RET]]
|
|
|
|
}
|
|
|
|
|
|
|
|
define i4 @test42(i4 %x, i4 %y) {
|
|
|
|
%a = and i4 %y, 7
|
|
|
|
%b = and i4 %x, 7
|
|
|
|
%c = sub i4 %a, %b
|
|
|
|
ret i4 %c
|
|
|
|
; CHECK-LABEL: @test42(
|
|
|
|
; CHECK-NEXT: [[AND:%.*]] = and i4 %y, 7
|
|
|
|
; CHECK-NEXT: [[AND1:%.*]] = and i4 %x, 7
|
2014-08-20 15:17:31 +08:00
|
|
|
; CHECK-NEXT: [[RET:%.*]] = sub nsw i4 [[AND]], [[AND1]]
|
|
|
|
; CHECK: ret i4 [[RET]]
|
|
|
|
}
|
|
|
|
|
|
|
|
define i4 @test43(i4 %x, i4 %y) {
|
|
|
|
%a = or i4 %x, -8
|
|
|
|
%b = and i4 %y, 7
|
|
|
|
%c = sub i4 %a, %b
|
|
|
|
ret i4 %c
|
|
|
|
; CHECK-LABEL: @test43(
|
|
|
|
; CHECK-NEXT: [[OR:%.*]] = or i4 %x, -8
|
|
|
|
; CHECK-NEXT: [[AND:%.*]] = and i4 %y, 7
|
|
|
|
; CHECK-NEXT: [[RET:%.*]] = sub nuw i4 [[OR]], [[AND]]
|
2014-08-20 07:36:30 +08:00
|
|
|
; CHECK: ret i4 [[RET]]
|
|
|
|
}
|
2014-08-23 00:41:23 +08:00
|
|
|
|
|
|
|
define i32 @test44(i32 %x) {
|
|
|
|
%sub = sub nsw i32 %x, 32768
|
|
|
|
ret i32 %sub
|
|
|
|
; CHECK-LABEL: @test44(
|
|
|
|
; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 %x, -32768
|
|
|
|
; CHECK: ret i32 [[ADD]]
|
|
|
|
}
|
2014-10-19 16:32:32 +08:00
|
|
|
|
|
|
|
define i32 @test45(i32 %x, i32 %y) {
|
|
|
|
%or = or i32 %x, %y
|
|
|
|
%xor = xor i32 %x, %y
|
|
|
|
%sub = sub i32 %or, %xor
|
|
|
|
ret i32 %sub
|
|
|
|
; CHECK-LABEL: @test45(
|
|
|
|
; CHECK-NEXT: %sub = and i32 %x, %y
|
|
|
|
; CHECK: ret i32 %sub
|
|
|
|
}
|
2014-11-03 13:53:55 +08:00
|
|
|
|
|
|
|
define i32 @test46(i32 %x, i32 %y) {
|
|
|
|
%or = or i32 %x, %y
|
|
|
|
%sub = sub i32 %or, %x
|
|
|
|
ret i32 %sub
|
|
|
|
; CHECK-LABEL: @test46(
|
|
|
|
; CHECK-NEXT: %x.not = xor i32 %x, -1
|
|
|
|
; CHECK-NEXT: %sub = and i32 %y, %x.not
|
|
|
|
; CHECK: ret i32 %sub
|
|
|
|
}
|
2015-06-23 10:49:24 +08:00
|
|
|
|
|
|
|
define i32 @test47(i1 %A, i32 %B, i32 %C, i32 %D) {
|
|
|
|
%sel0 = select i1 %A, i32 %D, i32 %B
|
|
|
|
%sel1 = select i1 %A, i32 %C, i32 %B
|
|
|
|
%sub = sub i32 %sel0, %sel1
|
|
|
|
ret i32 %sub
|
|
|
|
; CHECK-LABEL: @test47(
|
|
|
|
; CHECK-NEXT: %[[sub:.*]] = sub i32 %D, %C
|
|
|
|
; CHECK-NEXT: %[[sel:.*]] = select i1 %A, i32 %[[sub]], i32 0
|
|
|
|
; CHECK-NEXT: ret i32 %[[sel]]
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test48(i1 %A, i32 %B, i32 %C, i32 %D) {
|
|
|
|
%sel0 = select i1 %A, i32 %B, i32 %D
|
|
|
|
%sel1 = select i1 %A, i32 %B, i32 %C
|
|
|
|
%sub = sub i32 %sel0, %sel1
|
|
|
|
ret i32 %sub
|
|
|
|
; CHECK-LABEL: @test48(
|
|
|
|
; CHECK-NEXT: %[[sub:.*]] = sub i32 %D, %C
|
|
|
|
; CHECK-NEXT: %[[sel:.*]] = select i1 %A, i32 0, i32 %[[sub]]
|
|
|
|
; CHECK-NEXT: ret i32 %[[sel]]
|
|
|
|
}
|