Remove llvm-upgrade and update tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48103 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Tanya Lattner 2008-03-09 08:16:40 +00:00
parent 90b347dc90
commit 76806b6a43
65 changed files with 864 additions and 788 deletions

View File

@ -4,6 +4,7 @@
; RUN: llvm-as < %s | llc -march=alpha | grep gprel32 ; RUN: llvm-as < %s | llc -march=alpha | grep gprel32
; RUN: llvm-as < %s | llc -march=alpha | grep ldl ; RUN: llvm-as < %s | llc -march=alpha | grep ldl
; RUN: llvm-as < %s | llc -march=alpha | grep rodata ; RUN: llvm-as < %s | llc -march=alpha | grep rodata
; END.
target datalayout = "e-p:64:64" target datalayout = "e-p:64:64"
target triple = "alphaev67-unknown-linux-gnu" target triple = "alphaev67-unknown-linux-gnu"

View File

@ -1,8 +1,8 @@
; RUN: llvm-upgrade < %s | llvm-as > %t.bc ; RUN: llvm-as < %s > %t.bc
; RUN: echo | llvm-as > %t.tmp.bc ; RUN: echo | llvm-as > %t.tmp.bc
; RUN: llvm-link %t.tmp.bc %t.bc ; RUN: llvm-link %t.tmp.bc %t.bc
%X = constant int 5 @X = constant i32 5 ; <i32*> [#uses=2]
%Y = internal global [2 x int*] [ int* %X, int * %X] @Y = internal global [2 x i32*] [ i32* @X, i32* @X ] ; <[2 x i32*]*> [#uses=0]

View File

@ -1,9 +1,10 @@
; This fails linking when it is linked with an empty file as the first object file ; This fails linking when it is linked with an empty file as the first object file
; RUN: llvm-as > %t1.bc < /dev/null ; RUN: llvm-as > %t1.bc < /dev/null
; RUN: llvm-upgrade < %s | llvm-as > %t2.bc ; RUN: llvm-as < %s > %t2.bc
; RUN: llvm-link %t1.bc %t2.bc ; RUN: llvm-link %t1.bc %t2.bc
%work = global int (int, int)* %zip @work = global i32 (i32, i32)* @zip ; <i32 (i32, i32)**> [#uses=0]
declare i32 @zip(i32, i32)
declare int %zip(int, int)

View File

@ -1,9 +1,9 @@
; This fails linking when it is linked with an empty file as the first object file ; This fails linking when it is linked with an empty file as the first object file
; RUN: llvm-as > %t.LinkTest.bc < /dev/null ; RUN: llvm-as > %t.LinkTest.bc < /dev/null
; RUN: llvm-upgrade < %s | llvm-as > %t.bc ; RUN: llvm-as < %s > %t.bc
; RUN: llvm-link %t.LinkTest.bc %t.bc ; RUN: llvm-link %t.LinkTest.bc %t.bc
%work = global int 4 @work = global i32 4 ; <i32*> [#uses=1]
%test = global int* getelementptr( int* %work, long 1) @test = global i32* getelementptr (i32* @work, i64 1) ; <i32**> [#uses=0]

View File

@ -1,19 +1,17 @@
; This one fails because the LLVM runtime is allowing two null pointers of ; This one fails because the LLVM runtime is allowing two null pointers of
; the same type to be created! ; the same type to be created!
; RUN: echo {%T = type int} | llvm-upgrade | llvm-as > %t.2.bc ; RUN: echo {%T = type i32} | llvm-as > %t.2.bc
; RUN: llvm-upgrade < %s | llvm-as -f > %t.1.bc ; RUN: llvm-as < %s -f > %t.1.bc
; RUN: llvm-link %t.1.bc %t.2.bc ; RUN: llvm-link %t.1.bc %t.2.bc
%T = type opaque %T = type opaque
declare %T* %create() declare %T* @create()
implementation define void @test() {
%X = call %T* @create( ) ; <%T*> [#uses=1]
void %test() { %v = icmp eq %T* %X, null ; <i1> [#uses=0]
%X = call %T* %create()
%v = seteq %T* %X, null
ret void ret void
} }

View File

@ -2,9 +2,9 @@
; the same type to be created! ; the same type to be created!
; RUN: echo {%S = type \{ %T*\} %T = type opaque} | llvm-as > %t.2.bc ; RUN: echo {%S = type \{ %T*\} %T = type opaque} | llvm-as > %t.2.bc
; RUN: llvm-upgrade < %s | llvm-as > %t.1.bc ; RUN: llvm-as < %s > %t.1.bc
; RUN: llvm-link %t.1.bc %t.2.bc ; RUN: llvm-link %t.1.bc %t.2.bc
%S = type { %T* } %S = type { i32* }
%T = type int %T = type i32

View File

@ -1,7 +1,7 @@
; RUN: echo {%T = type opaque} | llvm-upgrade | llvm-as > %t.2.bc ; RUN: echo {%T = type opaque} | llvm-as > %t.2.bc
; RUN: llvm-upgrade < %s | llvm-as > %t.1.bc ; RUN: llvm-as < %s > %t.1.bc
; RUN: llvm-link %t.1.bc %t.2.bc ; RUN: llvm-link %t.1.bc %t.2.bc
%T = type opaque %T = type opaque
%a = constant { %T* } { %T* null } @a = constant { %T* } zeroinitializer ; <{ %T* }*> [#uses=0]

View File

@ -1,8 +1,7 @@
; RUN: echo {%T = type int} | llvm-upgrade | llvm-as > %t.1.bc ; RUN: echo {%T = type i32} | llvm-as > %t.1.bc
; RUN: llvm-upgrade < %s | llvm-as > %t.2.bc ; RUN: llvm-as < %s > %t.2.bc
; RUN: llvm-link %t.1.bc %t.2.bc ; RUN: llvm-link %t.1.bc %t.2.bc
%T = type opaque %T = type opaque
@X = constant { %T* } zeroinitializer ; <{ %T* }*> [#uses=0]
%X = constant {%T*} {%T* null }

View File

@ -1,7 +1,8 @@
; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc ; RUN: llvm-as < %s > %t.out1.bc
; RUN: echo {%S = type \{ int, int* \} } | llvm-upgrade | llvm-as > %t.out2.bc ; RUN: echo {%S = type \{ i32, i32* \} } | llvm-as > %t.out2.bc
; RUN: llvm-link %t.out1.bc %t.out2.bc ; RUN: llvm-link %t.out1.bc %t.out2.bc
%S = type { i32, %T* }
%T = type opaque %T = type opaque
%S = type { int, %T* }
;%X = global { int, %T* } { int 5, %T* null } ;%X = global { int, %T* } { int 5, %T* null }

View File

@ -1,10 +1,10 @@
; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc ; RUN: llvm-as < %s > %t.out1.bc
; RUN: echo {%S = external global \{ int, opaque* \} declare void %F(opaque*)}\ ; RUN: echo {@S = external global \{ i32, opaque* \} declare void @F(opaque*)}\
; RUN: | llvm-upgrade | llvm-as > %t.out2.bc ; RUN: | llvm-as > %t.out2.bc
; RUN: llvm-link %t.out1.bc %t.out2.bc | llvm-dis | not grep opaque ; RUN: llvm-link %t.out1.bc %t.out2.bc | llvm-dis | not grep opaque
; After linking this testcase, there should be no opaque types left. The two ; After linking this testcase, there should be no opaque types left. The two
; S's should cause the opaque type to be resolved to 'int'. ; S's should cause the opaque type to be resolved to 'int'.
%S = global { int, int* } { int 5, int* null } @S = global { i32, i32* } { i32 5, i32* null } ; <{ i32, i32* }*> [#uses=0]
declare void %F(int*) declare void @F(i32*)

View File

@ -1,8 +1,9 @@
; It's a bad idea to go recursively traipsing through types without a safety ; It's a bad idea to go recursively traipsing through types without a safety
; net. ; net.
; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc ; RUN: llvm-as < %s > %t.out1.bc
; RUN: echo "%S = type { %S*, int* }" | llvm-upgrade | llvm-as > %t.out2.bc ; RUN: echo "%S = type { %S*, i32* }" | llvm-as > %t.out2.bc
; RUN: llvm-link %t.out1.bc %t.out2.bc ; RUN: llvm-link %t.out1.bc %t.out2.bc
%S = type { %S*, opaque* } %S = type { %S*, opaque* }

View File

@ -1,12 +1,12 @@
; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc ; RUN: llvm-as < %s > %t.out1.bc
; RUN: echo "%S = type int" | llvm-upgrade | llvm-as > %t.out2.bc ; RUN: echo "%S = type i32" | llvm-as > %t.out2.bc
; RUN: llvm-link %t.out2.bc %t.out1.bc ; RUN: llvm-link %t.out2.bc %t.out1.bc
%S = type opaque %S = type opaque
void %foo(int* %V) { define void @foo(i32* %V) {
ret void ret void
} }
declare void %foo(%S*) declare void @foo.upgrd.1(%S*)

View File

@ -1,17 +1,18 @@
; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc ; RUN: llvm-as < %s > %t.out1.bc
; RUN: echo "%S = type int" | llvm-upgrade | llvm-as > %t.out2.bc ; RUN: echo "%S = type i32" | llvm-as > %t.out2.bc
; RUN: llvm-link %t.out2.bc %t.out1.bc ; RUN: llvm-link %t.out2.bc %t.out1.bc
%S = type opaque %S = type opaque
void %foo(int* %V) { define void @foo(i32* %V) {
ret void
}
declare void %foo(%S*)
void %other() {
call void %foo(%S* null) ; Add a use of the unresolved proto
call void %foo(int* null) ; Add a use of the resolved function
ret void ret void
} }
declare void @foo.upgrd.1(%S*)
define void @other() {
call void @foo.upgrd.1( %S* null )
call void @foo( i32* null )
ret void
}

View File

@ -1,15 +1,15 @@
; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc ; RUN: llvm-as < %s > %t.out1.bc
; RUN: echo "%S = type int" | llvm-upgrade | llvm-as > %t.out2.bc ; RUN: echo "%S = type i32" | llvm-as > %t.out2.bc
; RUN: llvm-link %t.out2.bc %t.out1.bc ; RUN: llvm-link %t.out2.bc %t.out1.bc
%S = type opaque %S = type opaque
; GLobal using the resolved function prototype ; GLobal using the resolved function prototype
global void(%S*)* %foo global void (%S*)* @foo ; <void (%S*)**>:0 [#uses=0]
void %foo(int* %V) { define void @foo.upgrd.1(i32* %V) {
ret void ret void
} }
declare void %foo(%S*) declare void @foo(%S*)

View File

@ -1,7 +1,7 @@
; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc ; RUN: llvm-as < %s > %t.out1.bc
; RUN: echo { %S = type \[8 x i32\] external global %S } | llvm-as > %t.out2.bc ; RUN: echo { %S = type \[8 x i32\] external global %S } | llvm-as > %t.out2.bc
; RUN: llvm-link %t.out1.bc %t.out2.bc | llvm-dis | grep %S | grep \{ ; RUN: llvm-link %t.out1.bc %t.out2.bc | llvm-dis | grep %S | grep \{
%S = type { int } %S = type { i32 }

View File

@ -1,8 +1,8 @@
; The linker should merge link-once globals into strong external globals, ; The linker should merge link-once globals into strong external globals,
; just like it does for weak symbols! ; just like it does for weak symbols!
; RUN: echo "%X = global int 7" | llvm-upgrade | llvm-as > %t.2.bc ; RUN: echo "@X = global i32 7" | llvm-as > %t.2.bc
; RUN: llvm-upgrade < %s | llvm-as > %t.1.bc ; RUN: llvm-as < %s > %t.1.bc
; RUN: llvm-link %t.1.bc %t.2.bc ; RUN: llvm-link %t.1.bc %t.2.bc
%X = linkonce global int 7 @X = linkonce global i32 7

View File

@ -3,6 +3,7 @@
; Test that -indvars can reduce variable stride IVs. If it can reduce variable ; Test that -indvars can reduce variable stride IVs. If it can reduce variable
; stride iv's, it will make %iv. and %m.0.0 isomorphic to each other without ; stride iv's, it will make %iv. and %m.0.0 isomorphic to each other without
; cycles, allowing the tmp.21 subtraction to be eliminated. ; cycles, allowing the tmp.21 subtraction to be eliminated.
; END.
define void @vnum_test8(i32* %data) { define void @vnum_test8(i32* %data) {
entry: entry:

View File

@ -6,6 +6,8 @@
; ;
; RUN: llvm-as < %s | opt -instcombine ; RUN: llvm-as < %s | opt -instcombine
; ;
; END.
@.LC0 = internal global [21 x i8] c"hbMakeCodeLengths(1)\00" ; <[21 x i8]*> [#uses=1] @.LC0 = internal global [21 x i8] c"hbMakeCodeLengths(1)\00" ; <[21 x i8]*> [#uses=1]
@.LC1 = internal global [21 x i8] c"hbMakeCodeLengths(2)\00" ; <[21 x i8]*> [#uses=1] @.LC1 = internal global [21 x i8] c"hbMakeCodeLengths(2)\00" ; <[21 x i8]*> [#uses=1]

View File

@ -11,7 +11,7 @@
; ;
; Extra code: ; Extra code:
; RUN: llvm-as < %s | opt -instcombine ; RUN: llvm-as < %s | opt -instcombine
; ; END.
target datalayout = "e-p:32:32" target datalayout = "e-p:32:32"
@silly = external constant i32 ; <i32*> [#uses=1] @silly = external constant i32 ; <i32*> [#uses=1]

View File

@ -11,7 +11,7 @@
; ;
; RUN: llvm-as < %s -o - | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s -o - | opt -instcombine | llvm-dis | \
; RUN: notcast .*int ; RUN: notcast .*int
; END.
define i1 @lt_signed_to_large_unsigned(i8 %SB) { define i1 @lt_signed_to_large_unsigned(i8 %SB) {
%Y = sext i8 %SB to i32 ; <i32> [#uses=1] %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
%C = icmp ult i32 %Y, 1024 ; <i1> [#uses=1] %C = icmp ult i32 %Y, 1024 ; <i1> [#uses=1]

View File

@ -1,4 +1,5 @@
; RUN: llvm-as < %s | opt -instcombine -disable-output ; RUN: llvm-as < %s | opt -instcombine -disable-output
; END.
%struct.DecRefPicMarking_s = type { i32, i32, i32, i32, i32, %struct.DecRefPicMarking_s* } %struct.DecRefPicMarking_s = type { i32, i32, i32, i32, i32, %struct.DecRefPicMarking_s* }
%struct.datapartition = type { %typedef.Bitstream*, %typedef.DecodingEnvironment, i32 (%struct.syntaxelement*, %struct.img_par*, %struct.inp_par*, %struct.datapartition*)* } %struct.datapartition = type { %typedef.Bitstream*, %typedef.DecodingEnvironment, i32 (%struct.syntaxelement*, %struct.img_par*, %struct.inp_par*, %struct.datapartition*)* }
%struct.img_par = type { i32, i32, i32, i32, i32*, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [16 x [16 x i16]], [6 x [32 x i32]], [16 x [16 x i32]], [4 x [12 x [4 x [4 x i32]]]], [16 x i32], i32**, i32*, i32***, i32**, i32, i32, i32, i32, %typedef.Slice*, %struct.macroblock*, i32, i32, i32, i32, i32, i32, i32**, %struct.DecRefPicMarking_s*, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [3 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32***, i32***, i32****, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %struct.timeb, %struct.timeb, i32, i32, i32, i32, i32, i32, i32, i32 } %struct.img_par = type { i32, i32, i32, i32, i32*, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [16 x [16 x i16]], [6 x [32 x i32]], [16 x [16 x i32]], [4 x [12 x [4 x [4 x i32]]]], [16 x i32], i32**, i32*, i32***, i32**, i32, i32, i32, i32, %typedef.Slice*, %struct.macroblock*, i32, i32, i32, i32, i32, i32, i32**, %struct.DecRefPicMarking_s*, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [3 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32***, i32***, i32****, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %struct.timeb, %struct.timeb, i32, i32, i32, i32, i32, i32, i32, i32 }

View File

@ -1,4 +1,5 @@
; RUN: llvm-as < %s | opt -instcombine -disable-output ; RUN: llvm-as < %s | opt -instcombine -disable-output
; END.
define void @test() { define void @test() {
bb38.i: bb38.i:

View File

@ -1,4 +1,5 @@
; RUN: llvm-as < %s | opt -instcombine -disable-output ; RUN: llvm-as < %s | opt -instcombine -disable-output
; END.
%struct.gs_matrix = type { float, i32, float, i32, float, i32, float, i32, float, i32, float, i32 } %struct.gs_matrix = type { float, i32, float, i32, float, i32, float, i32, float, i32, float, i32 }
%struct.gx_bitmap = type { i8*, i32, i32, i32 } %struct.gx_bitmap = type { i8*, i32, i32, i32 }
%struct.gx_device = type { i32, %struct.gx_device_procs*, i8*, i32, i32, float, float, i32, i16, i32, i32 } %struct.gx_device = type { i32, %struct.gx_device_procs*, i8*, i32, i32, float, float, i32, i16, i32, i32 }

View File

@ -1,5 +1,6 @@
; PR905 ; PR905
; RUN: llvm-as < %s | opt -instcombine -disable-output ; RUN: llvm-as < %s | opt -instcombine -disable-output
; END.
%RPYTHON_EXCEPTION = type { %RPYTHON_EXCEPTION_VTABLE* } %RPYTHON_EXCEPTION = type { %RPYTHON_EXCEPTION_VTABLE* }
%RPYTHON_EXCEPTION_VTABLE = type { %RPYTHON_EXCEPTION_VTABLE*, i32, i32, %RPyOpaque_RuntimeTypeInfo*, %arraytype_Char*, %functiontype_12* } %RPYTHON_EXCEPTION_VTABLE = type { %RPYTHON_EXCEPTION_VTABLE*, i32, i32, %RPyOpaque_RuntimeTypeInfo*, %arraytype_Char*, %functiontype_12* }

View File

@ -1,5 +1,6 @@
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: grep {icmp sgt} ; RUN: grep {icmp sgt}
; END.
target datalayout = "e-p:32:32" target datalayout = "e-p:32:32"
target triple = "i686-pc-linux-gnu" target triple = "i686-pc-linux-gnu"
%struct.point = type { i32, i32 } %struct.point = type { i32, i32 }

View File

@ -1,4 +1,5 @@
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep select ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep select
; END.
target datalayout = "e-p:32:32" target datalayout = "e-p:32:32"
target triple = "i686-pc-linux-gnu" target triple = "i686-pc-linux-gnu"

View File

@ -1,5 +1,6 @@
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: grep -v {icmp ult i32} ; RUN: grep -v {icmp ult i32}
; END.
target datalayout = "e-p:32:32" target datalayout = "e-p:32:32"
target triple = "i686-pc-linux-gnu" target triple = "i686-pc-linux-gnu"

View File

@ -2,6 +2,7 @@
; RUN: grep icmp | count 1 ; RUN: grep icmp | count 1
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: grep {icmp ugt} | count 1 ; RUN: grep {icmp ugt} | count 1
; END.
target datalayout = "e-p:32:32" target datalayout = "e-p:32:32"
target triple = "i686-pc-linux-gnu" target triple = "i686-pc-linux-gnu"

View File

@ -1,6 +1,7 @@
; For PR1065. This causes an assertion in instcombine if a select with two cmp ; For PR1065. This causes an assertion in instcombine if a select with two cmp
; operands is encountered. ; operands is encountered.
; RUN: llvm-as < %s | opt -instcombine -disable-output ; RUN: llvm-as < %s | opt -instcombine -disable-output
; END.
target datalayout = "e-p:32:32" target datalayout = "e-p:32:32"
target triple = "i686-pc-linux-gnu" target triple = "i686-pc-linux-gnu"

View File

@ -1,6 +1,5 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: grep select | not grep {i32\\*} ; RUN: grep select | not grep {i32\\*}
; END.
; This testcase corresponds to PR362, which notices that this horrible code ; This testcase corresponds to PR362, which notices that this horrible code
; is generated by the C++ front-end and LLVM optimizers, which has lots of ; is generated by the C++ front-end and LLVM optimizers, which has lots of
@ -9,28 +8,27 @@
; Instcombine should propagate the load through the select instructions to ; Instcombine should propagate the load through the select instructions to
; allow elimination of the extra stuff by the mem2reg pass. ; allow elimination of the extra stuff by the mem2reg pass.
implementation ; Functions: define void @_Z5test1RiS_(i32* %x, i32* %y) {
void %_Z5test1RiS_(int* %x, int* %y) {
entry: entry:
%tmp.1.i = load int* %y ; <int> [#uses=1] %tmp.1.i = load i32* %y ; <i32> [#uses=1]
%tmp.3.i = load int* %x ; <int> [#uses=1] %tmp.3.i = load i32* %x ; <i32> [#uses=1]
%tmp.4.i = setlt int %tmp.1.i, %tmp.3.i ; <bool> [#uses=1] %tmp.4.i = icmp slt i32 %tmp.1.i, %tmp.3.i ; <i1> [#uses=1]
%retval.i = select bool %tmp.4.i, int* %y, int* %x ; <int*> [#uses=1] %retval.i = select i1 %tmp.4.i, i32* %y, i32* %x ; <i32*> [#uses=1]
%tmp.4 = load int* %retval.i ; <int> [#uses=1] %tmp.4 = load i32* %retval.i ; <i32> [#uses=1]
store int %tmp.4, int* %x store i32 %tmp.4, i32* %x
ret void ret void
} }
void %_Z5test2RiS_(int* %x, int* %y) { define void @_Z5test2RiS_(i32* %x, i32* %y) {
entry: entry:
%tmp.0 = alloca int ; <int*> [#uses=2] %tmp.0 = alloca i32 ; <i32*> [#uses=2]
%tmp.2 = load int* %x ; <int> [#uses=2] %tmp.2 = load i32* %x ; <i32> [#uses=2]
store int %tmp.2, int* %tmp.0 store i32 %tmp.2, i32* %tmp.0
%tmp.3.i = load int* %y ; <int> [#uses=1] %tmp.3.i = load i32* %y ; <i32> [#uses=1]
%tmp.4.i = setlt int %tmp.2, %tmp.3.i ; <bool> [#uses=1] %tmp.4.i = icmp slt i32 %tmp.2, %tmp.3.i ; <i1> [#uses=1]
%retval.i = select bool %tmp.4.i, int* %y, int* %tmp.0 ; <int*> [#uses=1] %retval.i = select i1 %tmp.4.i, i32* %y, i32* %tmp.0 ; <i32*> [#uses=1]
%tmp.6 = load int* %retval.i ; <int> [#uses=1] %tmp.6 = load i32* %retval.i ; <i32> [#uses=1]
store int %tmp.6, int* %y store i32 %tmp.6, i32* %y
ret void ret void
} }

View File

@ -1,9 +1,10 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine -gcse -instcombine | \ ; RUN: llvm-as < %s | opt -instcombine -gcse -instcombine | \
; RUN: llvm-dis | not grep getelementptr ; RUN: llvm-dis | not grep getelementptr
bool %test(int* %A) { define i1 @test(i32* %A) {
%B = getelementptr int* %A, int 1 %B = getelementptr i32* %A, i32 1 ; <i32*> [#uses=1]
%C = getelementptr int* %A, uint 1 %C = getelementptr i32* %A, i64 1 ; <i32*> [#uses=1]
%V = seteq int* %B, %C %V = icmp eq i32* %B, %C ; <i1> [#uses=1]
ret bool %V ret i1 %V
} }

View File

@ -1,9 +1,9 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | notcast ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | notcast
target endian = little target datalayout = "e-p:32:32"
target pointersize = 32
int *%test(int *%P) { define i32* @test(i32* %P) {
%V = cast int* %P to int %V = ptrtoint i32* %P to i32 ; <i32> [#uses=1]
%P2 = cast int %V to int* %P2 = inttoptr i32 %V to i32* ; <i32*> [#uses=1]
ret int* %P2 ret i32* %P2
} }

View File

@ -1,15 +1,15 @@
; This is the sequence of stuff that the Java front-end expands for a single ; This is the sequence of stuff that the Java front-end expands for a single
; <= comparison. Check to make sure we turn it into a <= (only) ; <= comparison. Check to make sure we turn it into a <= (only)
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: grep -v {icmp sle} | not grep #uses ; RUN: grep -v {icmp sle} | not grep #uses
bool %le(int %A, int %B) { define i1 @le(i32 %A, i32 %B) {
%c1 = setgt int %A, %B; %c1 = icmp sgt i32 %A, %B ; <i1> [#uses=1]
%tmp = select bool %c1, int 1, int 0; %tmp = select i1 %c1, i32 1, i32 0 ; <i32> [#uses=1]
%c2 = setlt int %A, %B; %c2 = icmp slt i32 %A, %B ; <i1> [#uses=1]
%result = select bool %c2, int -1, int %tmp; %result = select i1 %c2, i32 -1, i32 %tmp ; <i32> [#uses=1]
%c3 = setle int %result, 0; %c3 = icmp sle i32 %result, 0 ; <i1> [#uses=1]
ret bool %c3; ret i1 %c3
} }

View File

@ -1,251 +1,270 @@
; This test makes sure that add instructions are properly eliminated. ; This test makes sure that add instructions are properly eliminated.
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: grep -v OK | not grep add ; RUN: grep -v OK | not grep add
; END.
implementation define i32 @test1(i32 %A) {
%B = add i32 %A, 0 ; <i32> [#uses=1]
int %test1(int %A) { ret i32 %B
%B = add int %A, 0
ret int %B
} }
int %test2(int %A) { define i32 @test2(i32 %A) {
%B = add int %A, 5 %B = add i32 %A, 5 ; <i32> [#uses=1]
%C = add int %B, -5 %C = add i32 %B, -5 ; <i32> [#uses=1]
ret int %C ret i32 %C
} }
int %test3(int %A) { define i32 @test3(i32 %A) {
%B = add int %A, 5 %B = add i32 %A, 5 ; <i32> [#uses=1]
%C = sub int %B, 5 ;; This should get converted to an add ;; This should get converted to an add
ret int %C %C = sub i32 %B, 5 ; <i32> [#uses=1]
ret i32 %C
} }
int %test4(int %A, int %B) { define i32 @test4(i32 %A, i32 %B) {
%C = sub int 0, %A %C = sub i32 0, %A ; <i32> [#uses=1]
%D = add int %B, %C ; D = B + -A = B - A ; D = B + -A = B - A
ret int %D %D = add i32 %B, %C ; <i32> [#uses=1]
ret i32 %D
} }
int %test5(int %A, int %B) { define i32 @test5(i32 %A, i32 %B) {
%C = sub int 0, %A %C = sub i32 0, %A ; <i32> [#uses=1]
%D = add int %C, %B ; D = -A + B = B - A ; D = -A + B = B - A
ret int %D %D = add i32 %C, %B ; <i32> [#uses=1]
ret i32 %D
} }
int %test6(int %A) { define i32 @test6(i32 %A) {
%B = mul int 7, %A %B = mul i32 7, %A ; <i32> [#uses=1]
%C = add int %B, %A ; C = 7*A+A == 8*A == A << 3 ; C = 7*A+A == 8*A == A << 3
ret int %C %C = add i32 %B, %A ; <i32> [#uses=1]
ret i32 %C
} }
int %test7(int %A) { define i32 @test7(i32 %A) {
%B = mul int 7, %A %B = mul i32 7, %A ; <i32> [#uses=1]
%C = add int %A, %B ; C = A+7*A == 8*A == A << 3 ; C = A+7*A == 8*A == A << 3
ret int %C %C = add i32 %A, %B ; <i32> [#uses=1]
ret i32 %C
} }
; (A & C1)+(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0 ; (A & C1)+(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0
int %test8(int %A, int %B) { define i32 @test8(i32 %A, i32 %B) {
%A1 = and int %A, 7 %A1 = and i32 %A, 7 ; <i32> [#uses=1]
%B1 = and int %B, 128 %B1 = and i32 %B, 128 ; <i32> [#uses=1]
%C = add int %A1, %B1 %C = add i32 %A1, %B1 ; <i32> [#uses=1]
ret int %C ret i32 %C
} }
int %test9(int %A) { define i32 @test9(i32 %A) {
%B = shl int %A, ubyte 4 %B = shl i32 %A, 4 ; <i32> [#uses=2]
%C = add int %B, %B ; === shl int %A, 5 ; === shl int %A, 5
ret int %C %C = add i32 %B, %B ; <i32> [#uses=1]
ret i32 %C
} }
bool %test10(ubyte %A, ubyte %b) { define i1 @test10(i8 %A, i8 %b) {
%B = add ubyte %A, %b %B = add i8 %A, %b ; <i8> [#uses=1]
%c = setne ubyte %B, 0 ; === A != -b ; === A != -b
ret bool %c %c = icmp ne i8 %B, 0 ; <i1> [#uses=1]
ret i1 %c
} }
bool %test11(ubyte %A) { define i1 @test11(i8 %A) {
%B = add ubyte %A, 255 %B = add i8 %A, -1 ; <i8> [#uses=1]
%c = setne ubyte %B, 0 ; === A != 1 ; === A != 1
ret bool %c %c = icmp ne i8 %B, 0 ; <i1> [#uses=1]
ret i1 %c
} }
int %test12(int %A, int %B) { define i32 @test12(i32 %A, i32 %B) {
%C_OK = add int %B, %A ; Should be transformed into shl A, 1 ; Should be transformed into shl A, 1
br label %X %C_OK = add i32 %B, %A ; <i32> [#uses=1]
X: br label %X
%D = add int %C_OK, %A
ret int %D X: ; preds = %0
%D = add i32 %C_OK, %A ; <i32> [#uses=1]
ret i32 %D
} }
int %test13(int %A, int %B, int %C) { define i32 @test13(i32 %A, i32 %B, i32 %C) {
%D_OK = add int %A, %B %D_OK = add i32 %A, %B ; <i32> [#uses=1]
%E_OK = add int %D_OK, %C %E_OK = add i32 %D_OK, %C ; <i32> [#uses=1]
%F = add int %E_OK, %A ;; shl A, 1 ;; shl A, 1
ret int %F %F = add i32 %E_OK, %A ; <i32> [#uses=1]
ret i32 %F
} }
uint %test14(uint %offset, uint %difference) { define i32 @test14(i32 %offset, i32 %difference) {
%tmp.2 = and uint %difference, 3 %tmp.2 = and i32 %difference, 3 ; <i32> [#uses=1]
%tmp.3_OK = add uint %tmp.2, %offset %tmp.3_OK = add i32 %tmp.2, %offset ; <i32> [#uses=1]
%tmp.5.mask = and uint %difference, 4294967292 %tmp.5.mask = and i32 %difference, -4 ; <i32> [#uses=1]
%tmp.8 = add uint %tmp.3_OK, %tmp.5.mask ; == add %offset, %difference ; == add %offset, %difference
ret uint %tmp.8 %tmp.8 = add i32 %tmp.3_OK, %tmp.5.mask ; <i32> [#uses=1]
ret i32 %tmp.8
} }
ubyte %test15(ubyte %A) { define i8 @test15(i8 %A) {
%B = add ubyte %A, 192 ; Does not effect result ; Does not effect result
%C = and ubyte %B, 16 ; Only one bit set %B = add i8 %A, -64 ; <i8> [#uses=1]
ret ubyte %C ; Only one bit set
%C = and i8 %B, 16 ; <i8> [#uses=1]
ret i8 %C
} }
ubyte %test16(ubyte %A) { define i8 @test16(i8 %A) {
%B = add ubyte %A, 16 ; Turn this into a XOR ; Turn this into a XOR
%C = and ubyte %B, 16 ; Only one bit set %B = add i8 %A, 16 ; <i8> [#uses=1]
ret ubyte %C ; Only one bit set
%C = and i8 %B, 16 ; <i8> [#uses=1]
ret i8 %C
} }
int %test17(int %A) { define i32 @test17(i32 %A) {
%B = xor int %A, -1 %B = xor i32 %A, -1 ; <i32> [#uses=1]
%C = add int %B, 1 ; == sub int 0, %A ; == sub int 0, %A
ret int %C %C = add i32 %B, 1 ; <i32> [#uses=1]
ret i32 %C
} }
ubyte %test18(ubyte %A) { define i8 @test18(i8 %A) {
%B = xor ubyte %A, 255 %B = xor i8 %A, -1 ; <i8> [#uses=1]
%C = add ubyte %B, 17 ; == sub ubyte 16, %A ; == sub ubyte 16, %A
ret ubyte %C %C = add i8 %B, 17 ; <i8> [#uses=1]
ret i8 %C
} }
int %test19(bool %C) { define i32 @test19(i1 %C) {
%A = select bool %C, int 1000, int 10 %A = select i1 %C, i32 1000, i32 10 ; <i32> [#uses=1]
%V = add int %A, 123 %V = add i32 %A, 123 ; <i32> [#uses=1]
ret int %V ret i32 %V
} }
int %test20(int %x) { define i32 @test20(i32 %x) {
%tmp.2 = xor int %x, -2147483648 %tmp.2 = xor i32 %x, -2147483648 ; <i32> [#uses=1]
;; Add of sign bit -> xor of sign bit. ;; Add of sign bit -> xor of sign bit.
%tmp.4 = add int %tmp.2, -2147483648 %tmp.4 = add i32 %tmp.2, -2147483648 ; <i32> [#uses=1]
ret int %tmp.4 ret i32 %tmp.4
} }
bool %test21(uint %x) { define i1 @test21(i32 %x) {
%t = add uint %x, 4 %t = add i32 %x, 4 ; <i32> [#uses=1]
%y = seteq uint %t, 123 %y = icmp eq i32 %t, 123 ; <i1> [#uses=1]
ret bool %y ret i1 %y
} }
int %test22(uint %V) { define i32 @test22(i32 %V) {
%V2 = add uint %V, 10 %V2 = add i32 %V, 10 ; <i32> [#uses=1]
switch uint %V2, label %Default [ switch i32 %V2, label %Default [
uint 20, label %Lab1 i32 20, label %Lab1
uint 30, label %Lab2 i32 30, label %Lab2
] ]
Default:
ret int 123 Default: ; preds = %0
Lab1: ret i32 123
ret int 12312
Lab2: Lab1: ; preds = %0
ret int 1231231 ret i32 12312
Lab2: ; preds = %0
ret i32 1231231
} }
int %test23(bool %C, int %a) { define i32 @test23(i1 %C, i32 %a) {
entry: entry:
br bool %C, label %endif, label %else br i1 %C, label %endif, label %else
else: else: ; preds = %entry
br label %endif br label %endif
endif: endif: ; preds = %else, %entry
%b.0 = phi int [ 0, %entry ], [ 1, %else ] %b.0 = phi i32 [ 0, %entry ], [ 1, %else ] ; <i32> [#uses=1]
%tmp.4 = add int %b.0, 1 %tmp.4 = add i32 %b.0, 1 ; <i32> [#uses=1]
ret int %tmp.4 ret i32 %tmp.4
} }
int %test24(int %A) { define i32 @test24(i32 %A) {
%B = add int %A, 1 %B = add i32 %A, 1 ; <i32> [#uses=1]
%C = shl int %B, ubyte 1 %C = shl i32 %B, 1 ; <i32> [#uses=1]
%D = sub int %C, 2 %D = sub i32 %C, 2 ; <i32> [#uses=1]
ret int %D ;; A << 1 ret i32 %D
} }
long %test25(long %Y) { define i64 @test25(i64 %Y) {
%tmp.4 = shl long %Y, ubyte 2 %tmp.4 = shl i64 %Y, 2 ; <i64> [#uses=1]
%tmp.12 = shl long %Y, ubyte 2 %tmp.12 = shl i64 %Y, 2 ; <i64> [#uses=1]
%tmp.8 = add long %tmp.4, %tmp.12 ;; Y << 3 %tmp.8 = add i64 %tmp.4, %tmp.12 ; <i64> [#uses=1]
ret long %tmp.8 ret i64 %tmp.8
} }
int %test26(int %A, int %B) { define i32 @test26(i32 %A, i32 %B) {
%C = add int %A, %B %C = add i32 %A, %B ; <i32> [#uses=1]
%D = sub int %C, %B %D = sub i32 %C, %B ; <i32> [#uses=1]
ret int %D ret i32 %D
} }
int %test27(bool %C, int %X, int %Y) { define i32 @test27(i1 %C, i32 %X, i32 %Y) {
%A = add int %X, %Y %A = add i32 %X, %Y ; <i32> [#uses=1]
%B = add int %Y, 123 %B = add i32 %Y, 123 ; <i32> [#uses=1]
%C = select bool %C, int %A, int %B ;; Fold add through select. ;; Fold add through select.
%D = sub int %C, %Y %C.upgrd.1 = select i1 %C, i32 %A, i32 %B ; <i32> [#uses=1]
ret int %D %D = sub i32 %C.upgrd.1, %Y ; <i32> [#uses=1]
ret i32 %D
} }
int %test28(int %X) { define i32 @test28(i32 %X) {
%Y = add int %X, 1234 %Y = add i32 %X, 1234 ; <i32> [#uses=1]
%Z = sub int 42, %Y %Z = sub i32 42, %Y ; <i32> [#uses=1]
ret int %Z ret i32 %Z
} }
uint %test29(uint %X, uint %x) { define i32 @test29(i32 %X, i32 %x) {
%tmp.2 = sub uint %X, %x %tmp.2 = sub i32 %X, %x ; <i32> [#uses=2]
%tmp.2.mask = and uint %tmp.2, 63 ; <uint> [#uses=1] %tmp.2.mask = and i32 %tmp.2, 63 ; <i32> [#uses=1]
%tmp.6 = add uint %tmp.2.mask, %x ; <uint> [#uses=1] %tmp.6 = add i32 %tmp.2.mask, %x ; <i32> [#uses=1]
%tmp.7 = and uint %tmp.6, 63 ; <uint> [#uses=1] %tmp.7 = and i32 %tmp.6, 63 ; <i32> [#uses=1]
%tmp.9 = and uint %tmp.2, 4294967232 ; <uint> [#uses=1] %tmp.9 = and i32 %tmp.2, -64 ; <i32> [#uses=1]
%tmp.10 = or uint %tmp.7, %tmp.9 ; <uint> [#uses=1] %tmp.10 = or i32 %tmp.7, %tmp.9 ; <i32> [#uses=1]
ret uint %tmp.10 ret i32 %tmp.10
} }
long %test30(long %x) { define i64 @test30(i64 %x) {
%tmp.2 = xor long %x, -9223372036854775808 %tmp.2 = xor i64 %x, -9223372036854775808 ; <i64> [#uses=1]
;; Add of sign bit -> xor of sign bit. ;; Add of sign bit -> xor of sign bit.
%tmp.4 = add long %tmp.2, -9223372036854775808 %tmp.4 = add i64 %tmp.2, -9223372036854775808 ; <i64> [#uses=1]
ret long %tmp.4 ret i64 %tmp.4
} }
int %test31(int %A) { define i32 @test31(i32 %A) {
%B = add int %A, 4 %B = add i32 %A, 4 ; <i32> [#uses=1]
%C = mul int %B, 5 %C = mul i32 %B, 5 ; <i32> [#uses=1]
%D = sub int %C, 20 %D = sub i32 %C, 20 ; <i32> [#uses=1]
ret int %D ret i32 %D
} }
int %test32(int %A) { define i32 @test32(i32 %A) {
%B = add int %A, 4 %B = add i32 %A, 4 ; <i32> [#uses=1]
%C = shl int %B, ubyte 2 %C = shl i32 %B, 2 ; <i32> [#uses=1]
%D = sub int %C, 16 %D = sub i32 %C, 16 ; <i32> [#uses=1]
ret int %D ret i32 %D
} }
ubyte %test33(ubyte %A) { ;; OR A, 1 define i8 @test33(i8 %A) {
%B = and ubyte %A, 254 %B = and i8 %A, -2 ; <i8> [#uses=1]
%C = add ubyte %B, 1 %C = add i8 %B, 1 ; <i8> [#uses=1]
ret ubyte %C ret i8 %C
} }
ubyte %test34(ubyte %A) { define i8 @test34(i8 %A) {
%B = add ubyte %A, 64 ;; dead %B = add i8 %A, 64 ; <i8> [#uses=1]
%C = and ubyte %B, 12 %C = and i8 %B, 12 ; <i8> [#uses=1]
ret ubyte %C ret i8 %C
} }
int %test35(int %a) { ;; -> -1 define i32 @test35(i32 %a) {
%tmpnot = xor int %a, -1 %tmpnot = xor i32 %a, -1 ; <i32> [#uses=1]
%tmp2 = add int %tmpnot, %a %tmp2 = add i32 %tmpnot, %a ; <i32> [#uses=1]
ret int %tmp2 ret i32 %tmp2
} }

View File

@ -1,29 +1,31 @@
; Zero byte allocas should be deleted. ; Zero byte allocas should be deleted.
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: not grep alloca ; RUN: not grep alloca
; END. ; END.
declare void %use(...) declare void @use(...)
void %test() {
%X = alloca [0 x int] define void @test() {
call void(...)* %use([0 x int] *%X) %X = alloca [0 x i32] ; <[0 x i32]*> [#uses=1]
%Y = alloca int, uint 0 call void (...)* @use( [0 x i32]* %X )
call void(...)* %use(int* %Y) %Y = alloca i32, i32 0 ; <i32*> [#uses=1]
%Z = alloca {} call void (...)* @use( i32* %Y )
call void(...)* %use({}* %Z) %Z = alloca { } ; <{ }*> [#uses=1]
ret void call void (...)* @use( { }* %Z )
ret void
} }
void %test2() { define void @test2() {
%A = alloca int ;; dead. %A = alloca i32 ; <i32*> [#uses=1]
store int 123, int* %A store i32 123, i32* %A
ret void ret void
} }
void %test3() { define void @test3() {
%A = alloca {int} ;; dead. %A = alloca { i32 } ; <{ i32 }*> [#uses=1]
%B = getelementptr {int}* %A, int 0, uint 0 %B = getelementptr { i32 }* %A, i32 0, i32 0 ; <i32*> [#uses=1]
store int 123, int* %B store i32 123, i32* %B
ret void ret void
} }

View File

@ -1,11 +1,11 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: grep and | count 1 ; RUN: grep and | count 1
; Should be optimized to one and. ; Should be optimized to one and.
bool %test1(uint %a, uint %b) { define i1 @test1(i32 %a, i32 %b) {
%tmp1 = and uint %a, 65280 %tmp1 = and i32 %a, 65280 ; <i32> [#uses=1]
%tmp3 = and uint %b, 65280 %tmp3 = and i32 %b, 65280 ; <i32> [#uses=1]
%tmp = setne uint %tmp1, %tmp3 %tmp = icmp ne i32 %tmp1, %tmp3 ; <i1> [#uses=1]
ret bool %tmp ret i1 %tmp
} }

View File

@ -9,48 +9,53 @@
; ;
; Which corresponds to test1. ; Which corresponds to test1.
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: not grep {or } ; RUN: not grep {or }
; END.
int %test1(int %X, int %Y) { define i32 @test1(i32 %X, i32 %Y) {
%A = and int %X, 7 %A = and i32 %X, 7 ; <i32> [#uses=1]
%B = and int %Y, 8 %B = and i32 %Y, 8 ; <i32> [#uses=1]
%C = or int %A, %B %C = or i32 %A, %B ; <i32> [#uses=1]
%D = and int %C, 7 ;; This cannot include any bits from %Y! ;; This cannot include any bits from %Y!
ret int %D %D = and i32 %C, 7 ; <i32> [#uses=1]
ret i32 %D
} }
int %test2(int %X, ubyte %Y) { define i32 @test2(i32 %X, i8 %Y) {
%B = cast ubyte %Y to int %B = zext i8 %Y to i32 ; <i32> [#uses=1]
%C = or int %X, %B %C = or i32 %X, %B ; <i32> [#uses=1]
%D = and int %C, 65536 ;; This cannot include any bits from %Y! ;; This cannot include any bits from %Y!
ret int %D %D = and i32 %C, 65536 ; <i32> [#uses=1]
ret i32 %D
} }
int %test3(int %X, int %Y) { define i32 @test3(i32 %X, i32 %Y) {
%B = shl int %Y, ubyte 1 %B = shl i32 %Y, 1 ; <i32> [#uses=1]
%C = or int %X, %B %C = or i32 %X, %B ; <i32> [#uses=1]
%D = and int %C, 1 ;; This cannot include any bits from %Y! ;; This cannot include any bits from %Y!
ret int %D %D = and i32 %C, 1 ; <i32> [#uses=1]
ret i32 %D
} }
uint %test4(uint %X, uint %Y) { define i32 @test4(i32 %X, i32 %Y) {
%B = shr uint %Y, ubyte 31 %B = lshr i32 %Y, 31 ; <i32> [#uses=1]
%C = or uint %X, %B %C = or i32 %X, %B ; <i32> [#uses=1]
%D = and uint %C, 2 ;; This cannot include any bits from %Y! ;; This cannot include any bits from %Y!
ret uint %D %D = and i32 %C, 2 ; <i32> [#uses=1]
ret i32 %D
} }
int %or_test1(int %X, int %Y) { define i32 @or_test1(i32 %X, i32 %Y) {
%A = and int %X, 1 %A = and i32 %X, 1 ; <i32> [#uses=1]
%B = or int %A, 1 ;; This cannot include any bits from X! ;; This cannot include any bits from X!
ret int %B %B = or i32 %A, 1 ; <i32> [#uses=1]
ret i32 %B
} }
ubyte %or_test2(ubyte %X, ubyte %Y) { define i8 @or_test2(i8 %X, i8 %Y) {
%A = shl ubyte %X, ubyte 7 %A = shl i8 %X, 7 ; <i8> [#uses=1]
%B = or ubyte %A, 128 ;; This cannot include any bits from X! ;; This cannot include any bits from X!
ret ubyte %B %B = or i8 %A, -128 ; <i8> [#uses=1]
ret i8 %B
} }

View File

@ -1,229 +1,255 @@
; This test makes sure that these instructions are properly eliminated. ; This test makes sure that these instructions are properly eliminated.
; ;
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not grep and ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep and
; END.
implementation define i32 @test1(i32 %A) {
; zero result
int %test1(int %A) { %B = and i32 %A, 0 ; <i32> [#uses=1]
%B = and int %A, 0 ; zero result ret i32 %B
ret int %B
} }
int %test2(int %A) { define i32 @test2(i32 %A) {
%B = and int %A, -1 ; noop ; noop
ret int %B %B = and i32 %A, -1 ; <i32> [#uses=1]
ret i32 %B
} }
bool %test3(bool %A) { define i1 @test3(i1 %A) {
%B = and bool %A, false ; always = false ; always = false
ret bool %B %B = and i1 %A, false ; <i1> [#uses=1]
ret i1 %B
} }
bool %test4(bool %A) { define i1 @test4(i1 %A) {
%B = and bool %A, true ; noop ; noop
ret bool %B %B = and i1 %A, true ; <i1> [#uses=1]
ret i1 %B
} }
int %test5(int %A) { define i32 @test5(i32 %A) {
%B = and int %A, %A %B = and i32 %A, %A ; <i32> [#uses=1]
ret int %B ret i32 %B
} }
bool %test6(bool %A) { define i1 @test6(i1 %A) {
%B = and bool %A, %A %B = and i1 %A, %A ; <i1> [#uses=1]
ret bool %B ret i1 %B
} }
int %test7(int %A) { ; A & ~A == 0 ; A & ~A == 0
%NotA = xor int %A, -1 define i32 @test7(i32 %A) {
%B = and int %A, %NotA %NotA = xor i32 %A, -1 ; <i32> [#uses=1]
ret int %B %B = and i32 %A, %NotA ; <i32> [#uses=1]
ret i32 %B
} }
ubyte %test8(ubyte %A) { ; AND associates ; AND associates
%B = and ubyte %A, 3 define i8 @test8(i8 %A) {
%C = and ubyte %B, 4 %B = and i8 %A, 3 ; <i8> [#uses=1]
ret ubyte %C %C = and i8 %B, 4 ; <i8> [#uses=1]
ret i8 %C
} }
bool %test9(int %A) { define i1 @test9(i32 %A) {
%B = and int %A, -2147483648 ; Test of sign bit, convert to setle %A, 0 ; Test of sign bit, convert to setle %A, 0
%C = setne int %B, 0 %B = and i32 %A, -2147483648 ; <i32> [#uses=1]
ret bool %C %C = icmp ne i32 %B, 0 ; <i1> [#uses=1]
ret i1 %C
} }
bool %test9(uint %A) { define i1 @test9a(i32 %A) {
%B = and uint %A, 2147483648 ; Test of sign bit, convert to setle %A, 0 ; Test of sign bit, convert to setle %A, 0
%C = setne uint %B, 0 %B = and i32 %A, -2147483648 ; <i32> [#uses=1]
ret bool %C %C = icmp ne i32 %B, 0 ; <i1> [#uses=1]
ret i1 %C
} }
uint %test10(uint %A) { define i32 @test10(i32 %A) {
%B = and uint %A, 12 %B = and i32 %A, 12 ; <i32> [#uses=1]
%C = xor uint %B, 15 %C = xor i32 %B, 15 ; <i32> [#uses=1]
%D = and uint %C, 1 ; (X ^ C1) & C2 --> (X & C2) ^ (C1&C2) ; (X ^ C1) & C2 --> (X & C2) ^ (C1&C2)
ret uint %D %D = and i32 %C, 1 ; <i32> [#uses=1]
ret i32 %D
} }
uint %test11(uint %A, uint* %P) { define i32 @test11(i32 %A, i32* %P) {
%B = or uint %A, 3 %B = or i32 %A, 3 ; <i32> [#uses=1]
%C = xor uint %B, 12 %C = xor i32 %B, 12 ; <i32> [#uses=2]
store uint %C, uint* %P ; additional use of C ; additional use of C
%D = and uint %C, 3 ; %C = and uint %B, 3 --> 3 store i32 %C, i32* %P
ret uint %D ; %C = and uint %B, 3 --> 3
%D = and i32 %C, 3 ; <i32> [#uses=1]
ret i32 %D
} }
bool %test12(uint %A, uint %B) { define i1 @test12(i32 %A, i32 %B) {
%C1 = setlt uint %A, %B %C1 = icmp ult i32 %A, %B ; <i1> [#uses=1]
%C2 = setle uint %A, %B %C2 = icmp ule i32 %A, %B ; <i1> [#uses=1]
%D = and bool %C1, %C2 ; (A < B) & (A <= B) === (A < B) ; (A < B) & (A <= B) === (A < B)
ret bool %D %D = and i1 %C1, %C2 ; <i1> [#uses=1]
ret i1 %D
} }
bool %test13(uint %A, uint %B) { define i1 @test13(i32 %A, i32 %B) {
%C1 = setlt uint %A, %B %C1 = icmp ult i32 %A, %B ; <i1> [#uses=1]
%C2 = setgt uint %A, %B %C2 = icmp ugt i32 %A, %B ; <i1> [#uses=1]
%D = and bool %C1, %C2 ; (A < B) & (A > B) === false ; (A < B) & (A > B) === false
ret bool %D %D = and i1 %C1, %C2 ; <i1> [#uses=1]
ret i1 %D
} }
bool %test14(ubyte %A) { define i1 @test14(i8 %A) {
%B = and ubyte %A, 128 %B = and i8 %A, -128 ; <i8> [#uses=1]
%C = setne ubyte %B, 0 %C = icmp ne i8 %B, 0 ; <i1> [#uses=1]
ret bool %C ret i1 %C
} }
ubyte %test15(ubyte %A) { define i8 @test15(i8 %A) {
%B = shr ubyte %A, ubyte 7 %B = lshr i8 %A, 7 ; <i8> [#uses=1]
%C = and ubyte %B, 2 ; Always equals zero ; Always equals zero
ret ubyte %C %C = and i8 %B, 2 ; <i8> [#uses=1]
ret i8 %C
} }
ubyte %test16(ubyte %A) { define i8 @test16(i8 %A) {
%B = shl ubyte %A, ubyte 2 %B = shl i8 %A, 2 ; <i8> [#uses=1]
%C = and ubyte %B, 3 %C = and i8 %B, 3 ; <i8> [#uses=1]
ret ubyte %C ret i8 %C
} }
sbyte %test17(sbyte %X, sbyte %Y) { ;; ~(~X & Y) --> (X | ~Y) ;; ~(~X & Y) --> (X | ~Y)
%B = xor sbyte %X, -1 define i8 @test17(i8 %X, i8 %Y) {
%C = and sbyte %B, %Y %B = xor i8 %X, -1 ; <i8> [#uses=1]
%D = xor sbyte %C, -1 %C = and i8 %B, %Y ; <i8> [#uses=1]
ret sbyte %D %D = xor i8 %C, -1 ; <i8> [#uses=1]
ret i8 %D
} }
bool %test18(int %A) { define i1 @test18(i32 %A) {
%B = and int %A, -128 %B = and i32 %A, -128 ; <i32> [#uses=1]
%C = setne int %B, 0 ;; C >= 128 ;; C >= 128
ret bool %C %C = icmp ne i32 %B, 0 ; <i1> [#uses=1]
ret i1 %C
} }
bool %test18a(ubyte %A) { define i1 @test18a(i8 %A) {
%B = and ubyte %A, 254 %B = and i8 %A, -2 ; <i8> [#uses=1]
%C = seteq ubyte %B, 0 %C = icmp eq i8 %B, 0 ; <i1> [#uses=1]
ret bool %C ret i1 %C
} }
int %test19(int %A) { define i32 @test19(i32 %A) {
%B = shl int %A, ubyte 3 %B = shl i32 %A, 3 ; <i32> [#uses=1]
%C = and int %B, -2 ;; Clearing a zero bit ;; Clearing a zero bit
ret int %C %C = and i32 %B, -2 ; <i32> [#uses=1]
ret i32 %C
} }
ubyte %test20(ubyte %A) { define i8 @test20(i8 %A) {
%C = shr ubyte %A, ubyte 7 %C = lshr i8 %A, 7 ; <i8> [#uses=1]
%D = and ubyte %C, 1 ;; Unneeded ;; Unneeded
ret ubyte %D %D = and i8 %C, 1 ; <i8> [#uses=1]
ret i8 %D
} }
bool %test22(int %A) { define i1 @test22(i32 %A) {
%B = seteq int %A, 1 %B = icmp eq i32 %A, 1 ; <i1> [#uses=1]
%C = setge int %A, 3 %C = icmp sge i32 %A, 3 ; <i1> [#uses=1]
%D = and bool %B, %C ;; False ;; false
ret bool %D %D = and i1 %B, %C ; <i1> [#uses=1]
ret i1 %D
} }
bool %test23(int %A) { define i1 @test23(i32 %A) {
%B = setgt int %A, 1 %B = icmp sgt i32 %A, 1 ; <i1> [#uses=1]
%C = setle int %A, 2 %C = icmp sle i32 %A, 2 ; <i1> [#uses=1]
%D = and bool %B, %C ;; A == 2 ;; A == 2
ret bool %D %D = and i1 %B, %C ; <i1> [#uses=1]
ret i1 %D
} }
bool %test24(int %A) { define i1 @test24(i32 %A) {
%B = setgt int %A, 1 %B = icmp sgt i32 %A, 1 ; <i1> [#uses=1]
%C = setne int %A, 2 %C = icmp ne i32 %A, 2 ; <i1> [#uses=1]
%D = and bool %B, %C ;; A > 2 ;; A > 2
ret bool %D %D = and i1 %B, %C ; <i1> [#uses=1]
ret i1 %D
} }
bool %test25(int %A) { define i1 @test25(i32 %A) {
%B = setge int %A, 50 %B = icmp sge i32 %A, 50 ; <i1> [#uses=1]
%C = setlt int %A, 100 %C = icmp slt i32 %A, 100 ; <i1> [#uses=1]
%D = and bool %B, %C ;; (A-50) <u 50 ;; (A-50) <u 50
ret bool %D %D = and i1 %B, %C ; <i1> [#uses=1]
ret i1 %D
} }
bool %test26(int %A) { define i1 @test26(i32 %A) {
%B = setne int %A, 50 %B = icmp ne i32 %A, 50 ; <i1> [#uses=1]
%C = setne int %A, 51 %C = icmp ne i32 %A, 51 ; <i1> [#uses=1]
%D = and bool %B, %C ;; (A-50) > 1 ;; (A-50) > 1
ret bool %D %D = and i1 %B, %C ; <i1> [#uses=1]
ret i1 %D
} }
ubyte %test27(ubyte %A) { define i8 @test27(i8 %A) {
%B = and ubyte %A, 4 %B = and i8 %A, 4 ; <i8> [#uses=1]
%C = sub ubyte %B, 16 %C = sub i8 %B, 16 ; <i8> [#uses=1]
%D = and ubyte %C, 240 ;; 0xF0 ;; 0xF0
%E = add ubyte %D, 16 %D = and i8 %C, -16 ; <i8> [#uses=1]
ret ubyte %E %E = add i8 %D, 16 ; <i8> [#uses=1]
ret i8 %E
} }
int %test28(int %X) { ;; This is juse a zero extending shr. ;; This is juse a zero extending shr.
%Y = shr int %X, ubyte 24 ;; Sign extend define i32 @test28(i32 %X) {
%Z = and int %Y, 255 ;; Mask out sign bits ;; Sign extend
ret int %Z %Y = ashr i32 %X, 24 ; <i32> [#uses=1]
;; Mask out sign bits
%Z = and i32 %Y, 255 ; <i32> [#uses=1]
ret i32 %Z
} }
int %test29(ubyte %X) { define i32 @test29(i8 %X) {
%Y = cast ubyte %X to int %Y = zext i8 %X to i32 ; <i32> [#uses=1]
%Z = and int %Y, 255 ;; Zero extend makes this unneeded. ;; Zero extend makes this unneeded.
ret int %Z %Z = and i32 %Y, 255 ; <i32> [#uses=1]
ret i32 %Z
} }
int %test30(bool %X) { define i32 @test30(i1 %X) {
%Y = cast bool %X to int %Y = zext i1 %X to i32 ; <i32> [#uses=1]
%Z = and int %Y, 1 %Z = and i32 %Y, 1 ; <i32> [#uses=1]
ret int %Z ret i32 %Z
} }
uint %test31(bool %X) { define i32 @test31(i1 %X) {
%Y = cast bool %X to uint %Y = zext i1 %X to i32 ; <i32> [#uses=1]
%Z = shl uint %Y, ubyte 4 %Z = shl i32 %Y, 4 ; <i32> [#uses=1]
%A = and uint %Z, 16 %A = and i32 %Z, 16 ; <i32> [#uses=1]
ret uint %A ret i32 %A
} }
uint %test32(uint %In) { define i32 @test32(i32 %In) {
%Y = and uint %In, 16 %Y = and i32 %In, 16 ; <i32> [#uses=1]
%Z = shr uint %Y, ubyte 2 %Z = lshr i32 %Y, 2 ; <i32> [#uses=1]
%A = and uint %Z, 1 %A = and i32 %Z, 1 ; <i32> [#uses=1]
ret uint %A ret i32 %A
} }
uint %test33(uint %b) { ;; Code corresponding to one-bit bitfield ^1. ;; Code corresponding to one-bit bitfield ^1.
%tmp.4.mask = and uint %b, 1 define i32 @test33(i32 %b) {
%tmp.10 = xor uint %tmp.4.mask, 1 %tmp.4.mask = and i32 %b, 1 ; <i32> [#uses=1]
%tmp.12 = and uint %b, 4294967294 %tmp.10 = xor i32 %tmp.4.mask, 1 ; <i32> [#uses=1]
%tmp.13 = or uint %tmp.12, %tmp.10 %tmp.12 = and i32 %b, -2 ; <i32> [#uses=1]
ret uint %tmp.13 %tmp.13 = or i32 %tmp.12, %tmp.10 ; <i32> [#uses=1]
ret i32 %tmp.13
} }
int %test34(int %A, int %B) { define i32 @test34(i32 %A, i32 %B) {
%tmp.2 = or int %B, %A %tmp.2 = or i32 %B, %A ; <i32> [#uses=1]
%tmp.4 = and int %tmp.2, %B %tmp.4 = and i32 %tmp.2, %B ; <i32> [#uses=1]
ret int %tmp.4 ret i32 %tmp.4
} }

View File

@ -1,26 +1,26 @@
; This file contains various testcases that require tracking whether bits are ; This file contains various testcases that require tracking whether bits are
; set or cleared by various instructions. ; set or cleared by various instructions.
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine -instcombine | llvm-dis |\ ; RUN: llvm-as < %s | opt -instcombine -instcombine | llvm-dis |\
; RUN: not grep %ELIM ; RUN: not grep %ELIM
; Reduce down to a single XOR ; Reduce down to a single XOR
int %test3(int %B) { define i32 @test3(i32 %B) {
%ELIMinc = and int %B, 1 %ELIMinc = and i32 %B, 1 ; <i32> [#uses=1]
%tmp.5 = xor int %ELIMinc, 1 %tmp.5 = xor i32 %ELIMinc, 1 ; <i32> [#uses=1]
%ELIM7 = and int %B, -2 %ELIM7 = and i32 %B, -2 ; <i32> [#uses=1]
%tmp.8 = or int %tmp.5, %ELIM7 %tmp.8 = or i32 %tmp.5, %ELIM7 ; <i32> [#uses=1]
ret int %tmp.8 ret i32 %tmp.8
} }
; Finally, a bigger case where we chain things together. This corresponds to ; Finally, a bigger case where we chain things together. This corresponds to
; incrementing a single-bit bitfield, which should become just an xor. ; incrementing a single-bit bitfield, which should become just an xor.
int %test4(int %B) { define i32 @test4(i32 %B) {
%ELIM3 = shl int %B, ubyte 31 %ELIM3 = shl i32 %B, 31 ; <i32> [#uses=1]
%ELIM4 = shr int %ELIM3, ubyte 31 %ELIM4 = ashr i32 %ELIM3, 31 ; <i32> [#uses=1]
%inc = add int %ELIM4, 1 %inc = add i32 %ELIM4, 1 ; <i32> [#uses=1]
%ELIM5 = and int %inc, 1 %ELIM5 = and i32 %inc, 1 ; <i32> [#uses=1]
%ELIM7 = and int %B, -2 %ELIM7 = and i32 %B, -2 ; <i32> [#uses=1]
%tmp.8 = or int %ELIM5, %ELIM7 %tmp.8 = or i32 %ELIM5, %ELIM7 ; <i32> [#uses=1]
ret int %tmp.8 ret i32 %tmp.8
} }

View File

@ -1,29 +1,30 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine -simplifycfg | llvm-dis |\ ; RUN: llvm-as < %s | opt -instcombine -simplifycfg | llvm-dis |\
; RUN: not grep {call void %abort} ; RUN: not grep {call void %abort}
%b_rec.0 = external global int @b_rec.0 = external global i32 ; <i32*> [#uses=2]
void %_Z12h000007_testv(uint *%P) { define void @_Z12h000007_testv(i32* %P) {
entry: entry:
%tmp.2 = load int* %b_rec.0 ; <int> [#uses=1] %tmp.2 = load i32* @b_rec.0 ; <i32> [#uses=1]
%tmp.9 = or int %tmp.2, -989855744 ; <int> [#uses=2] %tmp.9 = or i32 %tmp.2, -989855744 ; <i32> [#uses=2]
%tmp.16 = and int %tmp.9, -805306369 ; <int> [#uses=2] %tmp.16 = and i32 %tmp.9, -805306369 ; <i32> [#uses=2]
%tmp.17 = and int %tmp.9, -973078529 ; <int> [#uses=1] %tmp.17 = and i32 %tmp.9, -973078529 ; <i32> [#uses=1]
store int %tmp.17, int* %b_rec.0 store i32 %tmp.17, i32* @b_rec.0
%tmp.17.shrunk = cast int %tmp.16 to uint ; <uint> [#uses=1] %tmp.17.shrunk = bitcast i32 %tmp.16 to i32 ; <i32> [#uses=1]
%tmp.22 = and uint %tmp.17.shrunk, 3221225472 ; <uint> [#uses=1] %tmp.22 = and i32 %tmp.17.shrunk, -1073741824 ; <i32> [#uses=1]
%tmp.23 = seteq uint %tmp.22, 3221225472 ; <bool> [#uses=1] %tmp.23 = icmp eq i32 %tmp.22, -1073741824 ; <i1> [#uses=1]
br bool %tmp.23, label %endif.0, label %then.0 br i1 %tmp.23, label %endif.0, label %then.0
then.0: ; preds = %entry then.0: ; preds = %entry
tail call void %abort( ) tail call void @abort( )
unreachable unreachable
endif.0: ; preds = %entry endif.0: ; preds = %entry
%tmp.17.shrunk2 = cast int %tmp.16 to uint ; <uint> [#uses=1] %tmp.17.shrunk2 = bitcast i32 %tmp.16 to i32 ; <i32> [#uses=1]
%tmp.27.mask = and uint %tmp.17.shrunk2, 100663295 ; <uint> [#uses=1] %tmp.27.mask = and i32 %tmp.17.shrunk2, 100663295 ; <i32> [#uses=1]
store uint %tmp.27.mask, uint* %P store i32 %tmp.27.mask, i32* %P
ret void ret void
} }
declare void %abort() declare void @abort()

View File

@ -1,28 +1,29 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: grep ret | count 3 ; RUN: grep ret | count 3
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: not grep call.*bswap ; RUN: not grep call.*bswap
bool %test1(ushort %tmp2) { define i1 @test1(i16 %tmp2) {
%tmp10 = call ushort %llvm.bswap.i16( ushort %tmp2 ) %tmp10 = call i16 @llvm.bswap.i16( i16 %tmp2 ) ; <i16> [#uses=1]
%tmp = seteq ushort %tmp10, 1 %tmp = icmp eq i16 %tmp10, 1 ; <i1> [#uses=1]
ret bool %tmp ret i1 %tmp
} }
bool %test2(uint %tmp) { define i1 @test2(i32 %tmp) {
%tmp34 = tail call uint %llvm.bswap.i32( uint %tmp ) %tmp34 = tail call i32 @llvm.bswap.i32( i32 %tmp ) ; <i32> [#uses=1]
%tmp = seteq uint %tmp34, 1 %tmp.upgrd.1 = icmp eq i32 %tmp34, 1 ; <i1> [#uses=1]
ret bool %tmp ret i1 %tmp.upgrd.1
} }
declare uint %llvm.bswap.i32(uint) declare i32 @llvm.bswap.i32(i32)
bool %test3(ulong %tmp) { define i1 @test3(i64 %tmp) {
%tmp34 = tail call ulong %llvm.bswap.i64( ulong %tmp ) %tmp34 = tail call i64 @llvm.bswap.i64( i64 %tmp ) ; <i64> [#uses=1]
%tmp = seteq ulong %tmp34, 1 %tmp.upgrd.2 = icmp eq i64 %tmp34, 1 ; <i1> [#uses=1]
ret bool %tmp ret i1 %tmp.upgrd.2
} }
declare ulong %llvm.bswap.i64(ulong) declare i64 @llvm.bswap.i64(i64)
declare i16 @llvm.bswap.i16(i16)
declare ushort %llvm.bswap.i16(ushort)

View File

@ -1,62 +1,57 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: grep {call.*llvm.bswap} | count 5 ; RUN: grep {call.*llvm.bswap} | count 5
; END.
uint %test1(uint %i) { define i32 @test1(i32 %i) {
%tmp1 = shr uint %i, ubyte 24 ; <uint> [#uses=1] %tmp1 = lshr i32 %i, 24 ; <i32> [#uses=1]
%tmp3 = shr uint %i, ubyte 8 ; <uint> [#uses=1] %tmp3 = lshr i32 %i, 8 ; <i32> [#uses=1]
%tmp4 = and uint %tmp3, 65280 ; <uint> [#uses=1] %tmp4 = and i32 %tmp3, 65280 ; <i32> [#uses=1]
%tmp5 = or uint %tmp1, %tmp4 ; <uint> [#uses=1] %tmp5 = or i32 %tmp1, %tmp4 ; <i32> [#uses=1]
%tmp7 = shl uint %i, ubyte 8 ; <uint> [#uses=1] %tmp7 = shl i32 %i, 8 ; <i32> [#uses=1]
%tmp8 = and uint %tmp7, 16711680 ; <uint> [#uses=1] %tmp8 = and i32 %tmp7, 16711680 ; <i32> [#uses=1]
%tmp9 = or uint %tmp5, %tmp8 ; <uint> [#uses=1] %tmp9 = or i32 %tmp5, %tmp8 ; <i32> [#uses=1]
%tmp11 = shl uint %i, ubyte 24 ; <uint> [#uses=1] %tmp11 = shl i32 %i, 24 ; <i32> [#uses=1]
%tmp12 = or uint %tmp9, %tmp11 ; <uint> [#uses=1] %tmp12 = or i32 %tmp9, %tmp11 ; <i32> [#uses=1]
ret uint %tmp12 ret i32 %tmp12
} }
uint %test2(uint %arg) { define i32 @test2(i32 %arg) {
%tmp2 = shl uint %arg, ubyte 24 ; <uint> [#uses=1] %tmp2 = shl i32 %arg, 24 ; <i32> [#uses=1]
%tmp4 = shl uint %arg, ubyte 8 ; <uint> [#uses=1] %tmp4 = shl i32 %arg, 8 ; <i32> [#uses=1]
%tmp5 = and uint %tmp4, 16711680 ; <uint> [#uses=1] %tmp5 = and i32 %tmp4, 16711680 ; <i32> [#uses=1]
%tmp6 = or uint %tmp2, %tmp5 ; <uint> [#uses=1] %tmp6 = or i32 %tmp2, %tmp5 ; <i32> [#uses=1]
%tmp8 = shr uint %arg, ubyte 8 ; <uint> [#uses=1] %tmp8 = lshr i32 %arg, 8 ; <i32> [#uses=1]
%tmp9 = and uint %tmp8, 65280 ; <uint> [#uses=1] %tmp9 = and i32 %tmp8, 65280 ; <i32> [#uses=1]
%tmp10 = or uint %tmp6, %tmp9 ; <uint> [#uses=1] %tmp10 = or i32 %tmp6, %tmp9 ; <i32> [#uses=1]
%tmp12 = shr uint %arg, ubyte 24 ; <uint> [#uses=1] %tmp12 = lshr i32 %arg, 24 ; <i32> [#uses=1]
%tmp14 = or uint %tmp10, %tmp12 ; <uint> [#uses=1] %tmp14 = or i32 %tmp10, %tmp12 ; <i32> [#uses=1]
ret uint %tmp14 ret i32 %tmp14
} }
ushort %test3(ushort %s) { define i16 @test3(i16 %s) {
%tmp2 = shr ushort %s, ubyte 8 %tmp2 = lshr i16 %s, 8 ; <i16> [#uses=1]
%tmp4 = shl ushort %s, ubyte 8 %tmp4 = shl i16 %s, 8 ; <i16> [#uses=1]
%tmp5 = or ushort %tmp2, %tmp4 %tmp5 = or i16 %tmp2, %tmp4 ; <i16> [#uses=1]
ret ushort %tmp5 ret i16 %tmp5
} }
ushort %test4(ushort %s) { define i16 @test4(i16 %s) {
%tmp2 = shr ushort %s, ubyte 8 %tmp2 = lshr i16 %s, 8 ; <i16> [#uses=1]
%tmp4 = shl ushort %s, ubyte 8 %tmp4 = shl i16 %s, 8 ; <i16> [#uses=1]
%tmp5 = or ushort %tmp4, %tmp2 %tmp5 = or i16 %tmp4, %tmp2 ; <i16> [#uses=1]
ret ushort %tmp5 ret i16 %tmp5
} }
; unsigned short test5(unsigned short a) { define i16 @test5(i16 %a) {
; return ((a & 0xff00) >> 8 | (a & 0x00ff) << 8); %tmp = zext i16 %a to i32 ; <i32> [#uses=2]
;} %tmp1 = and i32 %tmp, 65280 ; <i32> [#uses=1]
ushort %test5(ushort %a) { %tmp2 = ashr i32 %tmp1, 8 ; <i32> [#uses=1]
%tmp = zext ushort %a to int %tmp2.upgrd.1 = trunc i32 %tmp2 to i16 ; <i16> [#uses=1]
%tmp1 = and int %tmp, 65280 %tmp4 = and i32 %tmp, 255 ; <i32> [#uses=1]
%tmp2 = ashr int %tmp1, ubyte 8 %tmp5 = shl i32 %tmp4, 8 ; <i32> [#uses=1]
%tmp2 = trunc int %tmp2 to short %tmp5.upgrd.2 = trunc i32 %tmp5 to i16 ; <i16> [#uses=1]
%tmp4 = and int %tmp, 255 %tmp.upgrd.3 = or i16 %tmp2.upgrd.1, %tmp5.upgrd.2 ; <i16> [#uses=1]
%tmp5 = shl int %tmp4, ubyte 8 %tmp6 = bitcast i16 %tmp.upgrd.3 to i16 ; <i16> [#uses=1]
%tmp5 = trunc int %tmp5 to short %tmp6.upgrd.4 = zext i16 %tmp6 to i32 ; <i32> [#uses=1]
%tmp = or short %tmp2, %tmp5 %retval = trunc i32 %tmp6.upgrd.4 to i16 ; <i16> [#uses=1]
%tmp6 = bitcast short %tmp to ushort ret i16 %retval
%tmp6 = zext ushort %tmp6 to int
%retval = trunc int %tmp6 to ushort
ret ushort %retval
} }

View File

@ -1,16 +1,14 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: grep call | not grep bitcast ; RUN: grep call | not grep bitcast
target endian = little target datalayout = "e-p:32:32"
target pointersize = 32
target triple = "i686-pc-linux-gnu" target triple = "i686-pc-linux-gnu"
implementation ; Functions: define i32 @main() {
int %main() {
entry: entry:
%tmp = call int cast (sbyte* (int*)* %ctime to int (int*)*)( int* null ) %tmp = call i32 bitcast (i8* (i32*)* @ctime to i32 (i32*)*)( i32* null ) ; <i32> [#uses=1]
ret int %tmp ret i32 %tmp
} }
declare sbyte* %ctime(int*) declare i8* @ctime(i32*)

View File

@ -1,17 +1,19 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis ; RUN: llvm-as < %s | opt -instcombine | llvm-dis
declare void %llvm.memmove.i32(sbyte*, sbyte*, uint, uint) @X = global i8 0 ; <i8*> [#uses=3]
declare void %llvm.memcpy.i32(sbyte*, sbyte*, uint, uint) @Y = global i8 12 ; <i8*> [#uses=2]
declare void %llvm.memset.i32(sbyte*, ubyte, uint, uint)
%X = global sbyte 0 declare void @llvm.memmove.i32(i8*, i8*, i32, i32)
%Y = global sbyte 12
void %zero_byte_test() { declare void @llvm.memcpy.i32(i8*, i8*, i32, i32)
; These process zero bytes, so they are a noop.
call void %llvm.memmove.i32(sbyte* %X, sbyte* %Y, uint 0, uint 100) declare void @llvm.memset.i32(i8*, i8, i32, i32)
call void %llvm.memcpy.i32(sbyte* %X, sbyte* %Y, uint 0, uint 100)
call void %llvm.memset.i32(sbyte* %X, ubyte 123, uint 0, uint 100) define void @zero_byte_test() {
ret void ; These process zero bytes, so they are a noop.
call void @llvm.memmove.i32( i8* @X, i8* @Y, i32 0, i32 100 )
call void @llvm.memcpy.i32( i8* @X, i8* @Y, i32 0, i32 100 )
call void @llvm.memset.i32( i8* @X, i8 123, i32 0, i32 100 )
ret void
} }

View File

@ -1,28 +1,36 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: not grep {setne\|setle\|setge} ; RUN: not grep {icmp ne\|icmp ule\|icmp uge}
int %test1(uint %X, uint %Y) { define i32 @test1(i32 %X, i32 %Y) {
%C = setne uint %X, %Y %C = icmp ne i32 %X, %Y ; <i1> [#uses=1]
br bool %C, label %T, label %F br i1 %C, label %T, label %F
T:
ret int 12 T: ; preds = %0
F: ret i32 12
ret int 123
F: ; preds = %0
ret i32 123
} }
int %test2(uint %X, uint %Y) { define i32 @test2(i32 %X, i32 %Y) {
%C = setle uint %X, %Y %C = icmp ule i32 %X, %Y ; <i1> [#uses=1]
br bool %C, label %T, label %F br i1 %C, label %T, label %F
T:
ret int 12 T: ; preds = %0
F: ret i32 12
ret int 123
F: ; preds = %0
ret i32 123
} }
int %test3(uint %X, uint %Y) {
%C = setge uint %X, %Y define i32 @test3(i32 %X, i32 %Y) {
br bool %C, label %T, label %F %C = icmp uge i32 %X, %Y ; <i1> [#uses=1]
T: br i1 %C, label %T, label %F
ret int 12
F: T: ; preds = %0
ret int 123 ret i32 12
F: ; preds = %0
ret i32 123
} }

View File

@ -1,16 +1,17 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: not grep bitcast ; RUN: not grep bitcast
bool %test1(uint %val) { define i1 @test1(i32 %val) {
%t1 = bitcast uint %val to int %t1 = bitcast i32 %val to i32 ; <i32> [#uses=1]
%t2 = and int %t1, 1 %t2 = and i32 %t1, 1 ; <i32> [#uses=1]
%t3 = trunc int %t2 to bool %t3 = trunc i32 %t2 to i1 ; <i1> [#uses=1]
ret bool %t3 ret i1 %t3
} }
short %test1(uint %val) { define i16 @test1.upgrd.1(i32 %val) {
%t1 = bitcast uint %val to int %t1 = bitcast i32 %val to i32 ; <i32> [#uses=1]
%t2 = and int %t1, 1 %t2 = and i32 %t1, 1 ; <i32> [#uses=1]
%t3 = trunc int %t2 to short %t3 = trunc i32 %t2 to i16 ; <i16> [#uses=1]
ret short %t3 ret i16 %t3
} }

View File

@ -1,9 +1,9 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: not grep ubyte ; RUN: not grep i8
int %test1(uint %X) { define i32 @test1(i32 %X) {
%Y = cast uint %X to ubyte ;; Turn into an AND %Y = trunc i32 %X to i8 ; <i8> [#uses=1]
%Z = cast ubyte %Y to int %Z = zext i8 %Y to i32 ; <i32> [#uses=1]
ret int %Z ret i32 %Z
} }

View File

@ -1,23 +1,20 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine -globaldce | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine -globaldce | llvm-dis | \
; RUN: not grep Array ; RUN: not grep Array
; Pulling the cast out of the load allows us to eliminate the load, and then ; Pulling the cast out of the load allows us to eliminate the load, and then
; the whole array. ; the whole array.
%unop = type {int } %op = type { float }
%op = type {float} %unop = type { i32 }
@Array = internal constant [1 x %op* (%op*)*] [ %op* (%op*)* @foo ] ; <[1 x %op* (%op*)*]*> [#uses=1]
%Array = internal constant [1 x %op* (%op*)*] [ %op* (%op*)* %foo ] define %op* @foo(%op* %X) {
ret %op* %X
implementation
%op* %foo(%op* %X) {
ret %op* %X
} }
%unop* %caller(%op* %O) { define %unop* @caller(%op* %O) {
%tmp = load %unop* (%op*)** cast ([1 x %op* (%op*)*]* %Array to %unop* (%op*)**) %tmp = load %unop* (%op*)** bitcast ([1 x %op* (%op*)*]* @Array to %unop* (%op*)**); <%unop* (%op*)*> [#uses=1]
%tmp.2 = call %unop* (%op*)* %tmp(%op* %O) %tmp.2 = call %unop* %tmp( %op* %O ) ; <%unop*> [#uses=1]
ret %unop* %tmp.2 ret %unop* %tmp.2
} }

View File

@ -1,13 +1,15 @@
; test that casted mallocs get converted to malloc of the right type ; test that casted mallocs get converted to malloc of the right type
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: not grep bitcast ; RUN: not grep bitcast
; The target datalayout is important for this test case. We have to tell ; The target datalayout is important for this test case. We have to tell
; instcombine that the ABI alignment for a long is 4-bytes, not 8, otherwise ; instcombine that the ABI alignment for a long is 4-bytes, not 8, otherwise
; it won't do the transform. ; it won't do the transform.
target datalayout = "e-i64:32:64" target datalayout = "e-i64:32:64"
int* %test(uint %size) {
%X = malloc long, uint %size define i32* @test(i32 %size) {
%ret = bitcast long* %X to int* %X = malloc i64, i32 %size ; <i64*> [#uses=1]
ret int* %ret %ret = bitcast i64* %X to i32* ; <i32*> [#uses=1]
ret i32* %ret
} }

View File

@ -1,10 +1,11 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine -mem2reg | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine -mem2reg | llvm-dis | \
; RUN: not grep load ; RUN: not grep load
int %test1(uint* %P) { define i32 @test1(i32* %P) {
%A = alloca uint %A = alloca i32 ; <i32*> [#uses=2]
store uint 123, uint* %A store i32 123, i32* %A
%Q = cast uint* %A to int* ; Cast the result of the load not the source ; Cast the result of the load not the source
%V = load int* %Q %Q = bitcast i32* %A to i32* ; <i32*> [#uses=1]
ret int %V %V = load i32* %Q ; <i32> [#uses=1]
ret i32 %V
} }

View File

@ -1,49 +1,51 @@
; This tests for various complex cast elimination cases instcombine should ; This tests for various complex cast elimination cases instcombine should
; handle. ; handle.
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | notcast ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | notcast
bool %test1(int %X) { define i1 @test1(i32 %X) {
%A = cast int %X to uint %A = bitcast i32 %X to i32 ; <i32> [#uses=1]
%c = setne uint %A, 12 ; Convert to setne int %X, 12 ; Convert to setne int %X, 12
ret bool %c %c = icmp ne i32 %A, 12 ; <i1> [#uses=1]
ret i1 %c
} }
bool %test2(int %X, int %Y) { define i1 @test2(i32 %X, i32 %Y) {
%A = cast int %X to uint %A = bitcast i32 %X to i32 ; <i32> [#uses=1]
%B = cast int %Y to uint %B = bitcast i32 %Y to i32 ; <i32> [#uses=1]
%c = setne uint %A, %B ; Convert to setne int %X, %Y ; Convert to setne int %X, %Y
ret bool %c %c = icmp ne i32 %A, %B ; <i1> [#uses=1]
ret i1 %c
} }
int %test4(int %A) { define i32 @test4(i32 %A) {
%B = cast int %A to uint %B = bitcast i32 %A to i32 ; <i32> [#uses=1]
%C = shl uint %B, ubyte 2 %C = shl i32 %B, 2 ; <i32> [#uses=1]
%D = cast uint %C to int %D = bitcast i32 %C to i32 ; <i32> [#uses=1]
ret int %D ret i32 %D
} }
short %test5(short %A) { define i16 @test5(i16 %A) {
%B = cast short %A to uint %B = sext i16 %A to i32 ; <i32> [#uses=1]
%C = and uint %B, 15 %C = and i32 %B, 15 ; <i32> [#uses=1]
%D = cast uint %C to short %D = trunc i32 %C to i16 ; <i16> [#uses=1]
ret short %D ret i16 %D
} }
bool %test6(bool %A) { define i1 @test6(i1 %A) {
%B = cast bool %A to int %B = zext i1 %A to i32 ; <i32> [#uses=1]
%C = setne int %B, 0 %C = icmp ne i32 %B, 0 ; <i1> [#uses=1]
ret bool %C ret i1 %C
} }
bool %test6a(bool %A) { define i1 @test6a(i1 %A) {
%B = cast bool %A to int %B = zext i1 %A to i32 ; <i32> [#uses=1]
%C = setne int %B, -1 ; Always true! %C = icmp ne i32 %B, -1 ; <i1> [#uses=1]
ret bool %C ret i1 %C
} }
bool %test7(sbyte* %A) { define i1 @test7(i8* %A) {
%B = cast sbyte* %A to int* %B = bitcast i8* %A to i32* ; <i32*> [#uses=1]
%C = seteq int* %B, null %C = icmp eq i32* %B, null ; <i1> [#uses=1]
ret bool %C ret i1 %C
} }

View File

@ -1,20 +1,19 @@
; Tests to make sure elimination of casts is working correctly ; Tests to make sure elimination of casts is working correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | notcast ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | notcast
target pointersize = 32 target datalayout = "p:32:32"
implementation define i8* @test1(i8* %t) {
%tmpc = ptrtoint i8* %t to i32 ; <i32> [#uses=1]
sbyte* %test1(sbyte* %t) { %tmpa = add i32 %tmpc, 32 ; <i32> [#uses=1]
%tmpc = cast sbyte* %t to uint %tv = inttoptr i32 %tmpa to i8* ; <i8*> [#uses=1]
%tmpa = add uint %tmpc, 32 ret i8* %tv
%tv = cast uint %tmpa to sbyte*
ret sbyte* %tv
} }
bool %test2(sbyte* %a, sbyte* %b) { define i1 @test2(i8* %a, i8* %b) {
%tmpa = cast sbyte* %a to uint %tmpa = ptrtoint i8* %a to i32 ; <i32> [#uses=1]
%tmpb = cast sbyte* %b to uint %tmpb = ptrtoint i8* %b to i32 ; <i32> [#uses=1]
%r = seteq uint %tmpa, %tmpb %r = icmp eq i32 %tmpa, %tmpb ; <i1> [#uses=1]
ret bool %r ret i1 %r
} }

View File

@ -1,14 +1,15 @@
; Test some floating point casting cases ; Test some floating point casting cases
; RUN: llvm-upgrade %s -o - | llvm-as | opt -instcombine | llvm-dis | notcast ; RUN: llvm-as %s -o - | opt -instcombine | llvm-dis | notcast
; RUN: llvm-upgrade %s -o - | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as %s -o - | opt -instcombine | llvm-dis | \
; RUN: egrep {ret i8 \(-1\)\|\(255\)} ; RUN: egrep {ret i8 \(-1\)\|\(255\)}
sbyte %test1() { define i8 @test1() {
%x = fptoui float 255.0 to sbyte %x = fptoui float 2.550000e+02 to i8 ; <i8> [#uses=1]
ret sbyte %x ret i8 %x
} }
ubyte %test2() { define i8 @test2() {
%x = fptosi float -1.0 to ubyte %x = fptosi float -1.000000e+00 to i8 ; <i8> [#uses=1]
ret ubyte %x ret i8 %x
} }

View File

@ -1,34 +1,31 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: not grep getelementptr ; RUN: not grep getelementptr
; END.
bool %test1(short* %P, int %I, int %J) { define i1 @test1(i16* %P, i32 %I, i32 %J) {
%X = getelementptr short* %P, int %I %X = getelementptr i16* %P, i32 %I ; <i16*> [#uses=1]
%Y = getelementptr short* %P, int %J %Y = getelementptr i16* %P, i32 %J ; <i16*> [#uses=1]
%C = icmp ult i16* %X, %Y ; <i1> [#uses=1]
%C = setlt short* %X, %Y ret i1 %C
ret bool %C
} }
bool %test2(short* %P, int %I) { define i1 @test2(i16* %P, i32 %I) {
%X = getelementptr short* %P, int %I %X = getelementptr i16* %P, i32 %I ; <i16*> [#uses=1]
%C = icmp ult i16* %X, %P ; <i1> [#uses=1]
%C = setlt short* %X, %P ret i1 %C
ret bool %C
} }
int %test3(int* %P, int %A, int %B) { define i32 @test3(i32* %P, i32 %A, i32 %B) {
%tmp.4 = getelementptr int* %P, int %A ; <int*> [#uses=1] %tmp.4 = getelementptr i32* %P, i32 %A ; <i32*> [#uses=1]
%tmp.9 = getelementptr int* %P, int %B ; <int*> [#uses=1] %tmp.9 = getelementptr i32* %P, i32 %B ; <i32*> [#uses=1]
%tmp.10 = seteq int* %tmp.4, %tmp.9 ; <bool> [#uses=1] %tmp.10 = icmp eq i32* %tmp.4, %tmp.9 ; <i1> [#uses=1]
%tmp.11 = cast bool %tmp.10 to int ; <int> [#uses=1] %tmp.11 = zext i1 %tmp.10 to i32 ; <i32> [#uses=1]
ret int %tmp.11 ret i32 %tmp.11
} }
int %test4(int* %P, int %A, int %B) { define i32 @test4(i32* %P, i32 %A, i32 %B) {
%tmp.4 = getelementptr int* %P, int %A ; <int*> [#uses=1] %tmp.4 = getelementptr i32* %P, i32 %A ; <i32*> [#uses=1]
%tmp.6 = seteq int* %tmp.4, %P ; <bool> [#uses=1] %tmp.6 = icmp eq i32* %tmp.4, %P ; <i1> [#uses=1]
%tmp.7 = cast bool %tmp.6 to int ; <int> [#uses=1] %tmp.7 = zext i1 %tmp.6 to i32 ; <i32> [#uses=1]
ret int %tmp.7 ret i32 %tmp.7
} }

View File

@ -1,11 +1,11 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: notcast {} {getelementptr.*} ; RUN: notcast {} {getelementptr.*}
%G = external global [3 x sbyte] @G = external global [3 x i8] ; <[3 x i8]*> [#uses=1]
implementation define i8* @foo(i32 %Idx) {
%gep.upgrd.1 = zext i32 %Idx to i64 ; <i64> [#uses=1]
ubyte *%foo(uint %Idx) { %tmp = getelementptr i8* getelementptr ([3 x i8]* @G, i32 0, i32 0), i64 %gep.upgrd.1 ; <i8*> [#uses=1]
%tmp = getelementptr ubyte* cast ([3 x sbyte]* %G to ubyte*), uint %Idx ret i8* %tmp
ret ubyte* %tmp
} }

View File

@ -1,14 +1,15 @@
; Test folding of constantexpr geps into normal geps. ; Test folding of constantexpr geps into normal geps.
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine -gcse -instcombine | \ ; RUN: llvm-as < %s | opt -instcombine -gcse -instcombine | \
; RUN: llvm-dis | not grep getelementptr ; RUN: llvm-dis | not grep getelementptr
%Array = external global [40 x int] @Array = external global [40 x i32] ; <[40 x i32]*> [#uses=2]
int %test(long %X) { define i32 @test(i64 %X) {
%A = getelementptr int* getelementptr ([40 x int]* %Array, long 0, long 0), long %X %A = getelementptr i32* getelementptr ([40 x i32]* @Array, i64 0, i64 0), i64 %X ; <i32*> [#uses=1]
%B = getelementptr [40 x int]* %Array, long 0, long %X %B = getelementptr [40 x i32]* @Array, i64 0, i64 %X ; <i32*> [#uses=1]
%a = cast int* %A to int %a = ptrtoint i32* %A to i32 ; <i32> [#uses=1]
%b = cast int* %B to int %b = ptrtoint i32* %B to i32 ; <i32> [#uses=1]
%c = sub int %a, %b %c = sub i32 %a, %b ; <i32> [#uses=1]
ret int %c ret i32 %c
} }

View File

@ -1,10 +1,9 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | grep trunc ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep trunc
target endian = little target datalayout = "e-p:32:32"
target pointersize = 32
int* %test(int* %X, long %Idx) { define i32* @test(i32* %X, i64 %Idx) {
; Should insert a cast to int on this target %R = getelementptr i32* %X, i64 %Idx ; <i32*> [#uses=1]
%R = getelementptr int* %X, long %Idx ret i32* %R
ret int* %R
} }

View File

@ -1,17 +1,17 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: %prcontext div 1 | grep then: ; RUN: %prcontext div 1 | grep then:
;; This tests that the div is hoisted into the then block. ;; This tests that the div is hoisted into the then block.
define i32 @foo(i1 %C, i32 %A, i32 %B) {
int %foo(bool %C, int %A, int %B) {
entry: entry:
br bool %C, label %then, label %endif br i1 %C, label %then, label %endif
then: then: ; preds = %entry
br label %endif br label %endif
endif: endif: ; preds = %then, %entry
%X = phi int [%A, %then], [15, %entry] %X = phi i32 [ %A, %then ], [ 15, %entry ] ; <i32> [#uses=1]
%Y = div int %X, 42 %Y = sdiv i32 %X, 42 ; <i32> [#uses=1]
ret int %Y ret i32 %Y
} }

View File

@ -1,6 +1,7 @@
; This test makes sure that these instructions are properly eliminated. ; This test makes sure that these instructions are properly eliminated.
; ;
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep icmp ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep icmp
; END.
@X = external global i32 ; <i32*> [#uses=2] @X = external global i32 ; <i32*> [#uses=2]

View File

@ -3,6 +3,7 @@
; been when a setcc is used with two casts. ; been when a setcc is used with two casts.
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: not grep {br bool false} ; RUN: not grep {br bool false}
; END.
define i32 @bug(i8 %inbuff) { define i32 @bug(i8 %inbuff) {
entry: entry:

View File

@ -4,7 +4,7 @@
; ;
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: grep -v {icmp eq} | grep -v {icmp ne} | not grep icmp ; RUN: grep -v {icmp eq} | grep -v {icmp ne} | not grep icmp
; END.
define i1 @test1(i32 %A) { define i1 @test1(i32 %A) {
; setne %A, 0 ; setne %A, 0

View File

@ -1,6 +1,7 @@
; This test makes sure that these instructions are properly eliminated. ; This test makes sure that these instructions are properly eliminated.
; ;
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep sh ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep sh
; END.
define i32 @test1(i32 %A) { define i32 @test1(i32 %A) {
%B = shl i32 %A, 0 ; <i32> [#uses=1] %B = shl i32 %A, 0 ; <i32> [#uses=1]

View File

@ -1,5 +1,6 @@
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: not grep {(and\|xor\|add\|shl\|shr)} ; RUN: not grep {(and\|xor\|add\|shl\|shr)}
; END.
define i32 @test1(i32 %x) { define i32 @test1(i32 %x) {
%tmp.1 = and i32 %x, 65535 ; <i32> [#uses=1] %tmp.1 = and i32 %x, 65535 ; <i32> [#uses=1]

View File

@ -4,6 +4,7 @@
; RUN: not grep insertelement ; RUN: not grep insertelement
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: not grep extractelement ; RUN: not grep extractelement
; END.
define <4 x float> @test(<4 x float> %tmp, <4 x float> %tmp1) { define <4 x float> @test(<4 x float> %tmp, <4 x float> %tmp1) {
%tmp4 = extractelement <4 x float> %tmp, i32 1 ; <float> [#uses=1] %tmp4 = extractelement <4 x float> %tmp, i32 1 ; <float> [#uses=1]

View File

@ -2,6 +2,7 @@
; ;
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
; RUN: not grep {xor } ; RUN: not grep {xor }
; END.
@G1 = global i32 0 ; <i32*> [#uses=1] @G1 = global i32 0 ; <i32*> [#uses=1]
@G2 = global i32 0 ; <i32*> [#uses=1] @G2 = global i32 0 ; <i32*> [#uses=1]