Upgrade tests.

llvm-svn: 48538
This commit is contained in:
Tanya Lattner 2008-03-19 07:28:33 +00:00
parent 966da4acc3
commit ab7872c06c
48 changed files with 2203 additions and 2351 deletions

View File

@ -1,77 +1,57 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce -disable-output
; RUN: llvm-as < %s | opt -loop-reduce -disable-output
void %try_swap() {
define void @try_swap() {
entry:
br bool false, label %cond_continue.0.i, label %cond_false.0.i
br i1 false, label %cond_continue.0.i, label %cond_false.0.i
cond_false.0.i: ; preds = %entry
ret void
cond_continue.0.i: ; preds = %entry
br bool false, label %cond_continue.1.i, label %cond_false.1.i
br i1 false, label %cond_continue.1.i, label %cond_false.1.i
cond_false.1.i: ; preds = %cond_continue.0.i
ret void
cond_continue.1.i: ; preds = %cond_continue.0.i
br bool false, label %endif.3.i, label %else.0.i
br i1 false, label %endif.3.i, label %else.0.i
endif.3.i: ; preds = %cond_continue.1.i
br bool false, label %my_irand.exit82, label %endif.0.i62
br i1 false, label %my_irand.exit82, label %endif.0.i62
else.0.i: ; preds = %cond_continue.1.i
ret void
endif.0.i62: ; preds = %endif.3.i
ret void
my_irand.exit82: ; preds = %endif.3.i
br bool false, label %else.2, label %then.4
br i1 false, label %else.2, label %then.4
then.4: ; preds = %my_irand.exit82
ret void
else.2: ; preds = %my_irand.exit82
br bool false, label %find_affected_nets.exit, label %loopentry.1.i107.outer.preheader
br i1 false, label %find_affected_nets.exit, label %loopentry.1.i107.outer.preheader
loopentry.1.i107.outer.preheader: ; preds = %else.2
ret void
find_affected_nets.exit: ; preds = %else.2
br bool false, label %save_region_occ.exit, label %loopentry.1
br i1 false, label %save_region_occ.exit, label %loopentry.1
save_region_occ.exit: ; preds = %find_affected_nets.exit
br bool false, label %no_exit.1.preheader, label %loopexit.1
br i1 false, label %no_exit.1.preheader, label %loopexit.1
loopentry.1: ; preds = %find_affected_nets.exit
ret void
no_exit.1.preheader: ; preds = %save_region_occ.exit
ret void
loopexit.1: ; preds = %save_region_occ.exit
br bool false, label %then.10, label %loopentry.3
br i1 false, label %then.10, label %loopentry.3
then.10: ; preds = %loopexit.1
ret void
loopentry.3: ; preds = %endif.16, %loopexit.1
%indvar342 = phi uint [ %indvar.next343, %endif.16 ], [ 0, %loopexit.1 ] ; <uint> [#uses=2]
br bool false, label %loopexit.3, label %endif.16
%indvar342 = phi i32 [ %indvar.next343, %endif.16 ], [ 0, %loopexit.1 ] ; <i32> [#uses=2]
br i1 false, label %loopexit.3, label %endif.16
endif.16: ; preds = %loopentry.3
%indvar.next343 = add uint %indvar342, 1 ; <uint> [#uses=1]
%indvar.next343 = add i32 %indvar342, 1 ; <i32> [#uses=1]
br label %loopentry.3
loopexit.3: ; preds = %loopentry.3
br label %loopentry.4
loopentry.4: ; preds = %loopentry.4, %loopexit.3
%indvar340 = phi uint [ 0, %loopexit.3 ], [ %indvar.next341, %loopentry.4 ] ; <uint> [#uses=2]
%tmp. = add uint %indvar340, %indvar342 ; <uint> [#uses=1]
%tmp.526 = load int** null ; <int*> [#uses=1]
%tmp.528 = getelementptr int* %tmp.526, uint %tmp. ; <int*> [#uses=1]
store int 0, int* %tmp.528
%indvar.next341 = add uint %indvar340, 1 ; <uint> [#uses=1]
%indvar340 = phi i32 [ 0, %loopexit.3 ], [ %indvar.next341, %loopentry.4 ] ; <i32> [#uses=2]
%tmp. = add i32 %indvar340, %indvar342 ; <i32> [#uses=1]
%tmp.526 = load i32** null ; <i32*> [#uses=1]
%gep.upgrd.1 = zext i32 %tmp. to i64 ; <i64> [#uses=1]
%tmp.528 = getelementptr i32* %tmp.526, i64 %gep.upgrd.1 ; <i32*> [#uses=1]
store i32 0, i32* %tmp.528
%indvar.next341 = add i32 %indvar340, 1 ; <i32> [#uses=1]
br label %loopentry.4
}

View File

@ -1,18 +1,17 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce -disable-output
; RUN: llvm-as < %s | opt -loop-reduce -disable-output
int %image_to_texture(uint %indvar454) {
define i32 @image_to_texture(i32 %indvar454) {
loopentry.1.outer:
%j.2.1.ph = cast uint %indvar454 to int ; <int> [#uses=1]
%j.2.1.ph = bitcast i32 %indvar454 to i32 ; <i32> [#uses=1]
br label %loopentry.1
loopentry.1: ; preds = %label.5, %loopentry.1.outer
%i.3 = phi int [ 0, %loopentry.1.outer ], [ %i.3.be, %loopentry.1 ]
%tmp.390 = load int* null ; <int> [#uses=1]
%tmp.392 = mul int %tmp.390, %j.2.1.ph ; <int> [#uses=1]
%tmp.394 = add int %tmp.392, %i.3 ; <int> [#uses=1]
%i.3.be = add int %i.3, 1 ; <int> [#uses=1]
br bool false, label %loopentry.1, label %label.6
label.6: ; preds = %no_exit.1
ret int %tmp.394
loopentry.1: ; preds = %loopentry.1, %loopentry.1.outer
%i.3 = phi i32 [ 0, %loopentry.1.outer ], [ %i.3.be, %loopentry.1 ] ; <i32> [#uses=2]
%tmp.390 = load i32* null ; <i32> [#uses=1]
%tmp.392 = mul i32 %tmp.390, %j.2.1.ph ; <i32> [#uses=1]
%tmp.394 = add i32 %tmp.392, %i.3 ; <i32> [#uses=1]
%i.3.be = add i32 %i.3, 1 ; <i32> [#uses=1]
br i1 false, label %loopentry.1, label %label.6
label.6: ; preds = %loopentry.1
ret i32 %tmp.394
}

View File

@ -1,43 +1,32 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce -disable-output
; RUN: llvm-as < %s | opt -loop-reduce -disable-output
void %main() {
define void @main() {
entry:
br label %loopentry.0
loopentry.0: ; preds = %then.5, %entry
%arg_index.1.ph = phi int [ 1, %entry ], [ %arg_index.1.ph.be, %then.5 ] ; <int> [#uses=1]
br bool false, label %no_exit.0, label %loopexit.0
%arg_index.1.ph = phi i32 [ 1, %entry ], [ %arg_index.1.ph.be, %then.5 ] ; <i32> [#uses=1]
br i1 false, label %no_exit.0, label %loopexit.0
no_exit.0: ; preds = %loopentry.0
%arg_index.1.1 = add int 0, %arg_index.1.ph ; <int> [#uses=2]
br bool false, label %then.i55, label %endif.i61
%arg_index.1.1 = add i32 0, %arg_index.1.ph ; <i32> [#uses=2]
br i1 false, label %then.i55, label %endif.i61
then.i55: ; preds = %no_exit.0
br bool false, label %then.4, label %else.1
br i1 false, label %then.4, label %else.1
endif.i61: ; preds = %no_exit.0
ret void
then.4: ; preds = %then.i55
%tmp.19993 = add int %arg_index.1.1, 2 ; <int> [#uses=0]
%tmp.19993 = add i32 %arg_index.1.1, 2 ; <i32> [#uses=0]
ret void
else.1: ; preds = %then.i55
br bool false, label %then.i86, label %loopexit.i97
br i1 false, label %then.i86, label %loopexit.i97
then.i86: ; preds = %else.1
ret void
loopexit.i97: ; preds = %else.1
br bool false, label %then.5, label %else.2
br i1 false, label %then.5, label %else.2
then.5: ; preds = %loopexit.i97
%arg_index.1.ph.be = add int %arg_index.1.1, 2 ; <int> [#uses=1]
%arg_index.1.ph.be = add i32 %arg_index.1.1, 2 ; <i32> [#uses=1]
br label %loopentry.0
else.2: ; preds = %loopexit.i97
ret void
loopexit.0: ; preds = %loopentry.0
ret void
}

View File

@ -1,26 +1,25 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce -disable-output
; RUN: llvm-as < %s | opt -loop-reduce -disable-output
; Test to make sure that loop-reduce never crashes on IV's
; with different types but identical strides.
void %foo() {
define void @foo() {
entry:
br label %no_exit
no_exit: ; preds = %no_exit, %entry
%indvar = phi uint [ 0, %entry ], [ %indvar.next, %no_exit ] ; <uint> [#uses=3]
%indvar = cast uint %indvar to short ; <short> [#uses=1]
%X.0.0 = mul short %indvar, 1234 ; <short> [#uses=1]
%tmp. = mul uint %indvar, 1234 ; <uint> [#uses=1]
%tmp.5 = cast short %X.0.0 to int ; <int> [#uses=1]
%tmp.3 = call int (...)* %bar( int %tmp.5, uint %tmp. ) ; <int> [#uses=0]
%tmp.0 = call bool %pred( ) ; <int> [#uses=1]
%indvar.next = add uint %indvar, 1 ; <uint> [#uses=1]
br bool %tmp.0, label %return, label %no_exit
return:
%indvar = phi i32 [ 0, %entry ], [ %indvar.next, %no_exit ] ; <i32> [#uses=3]
%indvar.upgrd.1 = trunc i32 %indvar to i16 ; <i16> [#uses=1]
%X.0.0 = mul i16 %indvar.upgrd.1, 1234 ; <i16> [#uses=1]
%tmp. = mul i32 %indvar, 1234 ; <i32> [#uses=1]
%tmp.5 = sext i16 %X.0.0 to i32 ; <i32> [#uses=1]
%tmp.3 = call i32 (...)* @bar( i32 %tmp.5, i32 %tmp. ) ; <i32> [#uses=0]
%tmp.0 = call i1 @pred( ) ; <i1> [#uses=1]
%indvar.next = add i32 %indvar, 1 ; <i32> [#uses=1]
br i1 %tmp.0, label %return, label %no_exit
return: ; preds = %no_exit
ret void
}
declare bool %pred()
declare i1 @pred()
declare i32 @bar(...)
declare int %bar(...)

View File

@ -1,26 +1,23 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | \
; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | \
; RUN: not grep {cast uint 1 to uint}
; END.
; The setlt wants to use a value that is incremented one more than the dominant
; IV. Don't insert the 1 outside the loop, preventing folding it into the add.
implementation ; Functions:
void %test([700 x int]* %nbeaux_.0__558, int* %i_.16574) {
define void @test([700 x i32]* %nbeaux_.0__558, i32* %i_.16574) {
then.0:
br label %no_exit.2
no_exit.2: ; preds = %no_exit.2, %then.0
%indvar630 = phi uint [ 0, %then.0 ], [ %indvar.next631, %no_exit.2 ] ; <uint> [#uses=3]
%indvar630 = cast uint %indvar630 to int ; <int> [#uses=1]
%tmp.38 = getelementptr [700 x int]* %nbeaux_.0__558, int 0, uint %indvar630 ; <int*> [#uses=1]
store int 0, int* %tmp.38
%inc.2 = add int %indvar630, 2 ; <int> [#uses=2]
%tmp.34 = setlt int %inc.2, 701 ; <bool> [#uses=1]
%indvar.next631 = add uint %indvar630, 1 ; <uint> [#uses=1]
br bool %tmp.34, label %no_exit.2, label %loopexit.2.loopexit
loopexit.2.loopexit: ; preds = %no_exit.2
store int %inc.2, int* %i_.16574
ret void
br label %no_exit.2
no_exit.2: ; preds = %no_exit.2, %then.0
%indvar630 = phi i32 [ 0, %then.0 ], [ %indvar.next631, %no_exit.2 ] ; <i32> [#uses=4]
%gep.upgrd.1 = zext i32 %indvar630 to i64 ; <i64> [#uses=1]
%tmp.38 = getelementptr [700 x i32]* %nbeaux_.0__558, i32 0, i64 %gep.upgrd.1 ; <i32*> [#uses=1]
store i32 0, i32* %tmp.38
%inc.2 = add i32 %indvar630, 2 ; <i32> [#uses=2]
%tmp.34 = icmp slt i32 %inc.2, 701 ; <i1> [#uses=1]
%indvar.next631 = add i32 %indvar630, 1 ; <i32> [#uses=1]
br i1 %tmp.34, label %no_exit.2, label %loopexit.2.loopexit
loopexit.2.loopexit: ; preds = %no_exit.2
store i32 %inc.2, i32* %i_.16574
ret void
}

View File

@ -1,40 +1,36 @@
; Check that this test makes INDVAR and related stuff dead.
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | grep phi | count 2
; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | grep phi | count 2
declare bool %pred()
declare i1 @pred()
void %test1({ int, int }* %P) {
define void @test1({ i32, i32 }* %P) {
; <label>:0
br label %Loop
Loop:
%INDVAR = phi int [0, %0], [%INDVAR2, %Loop]
%gep1 = getelementptr { int, int}* %P, int %INDVAR, uint 0
store int 0, int* %gep1
%gep2 = getelementptr { int, int}* %P, int %INDVAR, uint 1
store int 0, int* %gep2
%INDVAR2 = add int %INDVAR, 1
%cond = call bool %pred()
br bool %cond, label %Loop, label %Out
Out:
Loop: ; preds = %Loop, %0
%INDVAR = phi i32 [ 0, %0 ], [ %INDVAR2, %Loop ] ; <i32> [#uses=3]
%gep1 = getelementptr { i32, i32 }* %P, i32 %INDVAR, i32 0 ; <i32*> [#uses=1]
store i32 0, i32* %gep1
%gep2 = getelementptr { i32, i32 }* %P, i32 %INDVAR, i32 1 ; <i32*> [#uses=1]
store i32 0, i32* %gep2
%INDVAR2 = add i32 %INDVAR, 1 ; <i32> [#uses=1]
%cond = call i1 @pred( ) ; <i1> [#uses=1]
br i1 %cond, label %Loop, label %Out
Out: ; preds = %Loop
ret void
}
void %test2([2 x int]* %P) {
define void @test2([2 x i32]* %P) {
; <label>:0
br label %Loop
Loop:
%INDVAR = phi int [0, %0], [%INDVAR2, %Loop]
%gep1 = getelementptr [2 x int]* %P, int %INDVAR, uint 0
store int 0, int* %gep1
%gep2 = getelementptr [2 x int]* %P, int %INDVAR, uint 1
store int 0, int* %gep2
%INDVAR2 = add int %INDVAR, 1
%cond = call bool %pred()
br bool %cond, label %Loop, label %Out
Out:
Loop: ; preds = %Loop, %0
%INDVAR = phi i32 [ 0, %0 ], [ %INDVAR2, %Loop ] ; <i32> [#uses=3]
%gep1 = getelementptr [2 x i32]* %P, i32 %INDVAR, i64 0 ; <i32*> [#uses=1]
store i32 0, i32* %gep1
%gep2 = getelementptr [2 x i32]* %P, i32 %INDVAR, i64 1 ; <i32*> [#uses=1]
store i32 0, i32* %gep2
%INDVAR2 = add i32 %INDVAR, 1 ; <i32> [#uses=1]
%cond = call i1 @pred( ) ; <i1> [#uses=1]
br i1 %cond, label %Loop, label %Out
Out: ; preds = %Loop
ret void
}

View File

@ -1,21 +1,22 @@
; Don't reduce the byte access to P[i], at least not on targets that
; support an efficient 'mem[r1+r2]' addressing mode.
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce -disable-output
; RUN: llvm-as < %s | opt -loop-reduce -disable-output
declare bool %pred(int)
void %test(sbyte* %PTR) {
declare i1 @pred(i32)
define void @test(i8* %PTR) {
; <label>:0
br label %Loop
Loop:
%INDVAR = phi int [0, %0], [%INDVAR2, %Loop]
%STRRED = getelementptr sbyte* %PTR, int %INDVAR
store sbyte 0, sbyte* %STRRED
%INDVAR2 = add int %INDVAR, 1
%cond = call bool %pred(int %INDVAR2) ;; cannot eliminate indvar
br bool %cond, label %Loop, label %Out
Out:
Loop: ; preds = %Loop, %0
%INDVAR = phi i32 [ 0, %0 ], [ %INDVAR2, %Loop ] ; <i32> [#uses=2]
%STRRED = getelementptr i8* %PTR, i32 %INDVAR ; <i8*> [#uses=1]
store i8 0, i8* %STRRED
%INDVAR2 = add i32 %INDVAR, 1 ; <i32> [#uses=2]
;; cannot eliminate indvar
%cond = call i1 @pred( i32 %INDVAR2 ) ; <i1> [#uses=1]
br i1 %cond, label %Loop, label %Out
Out: ; preds = %Loop
ret void
}

View File

@ -2,20 +2,19 @@
; having overlapping live ranges that result in copies. We want the setcc
; instruction immediately before the conditional branch.
;
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | \
; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | \
; RUN: %prcontext {br i1} 1 | grep icmp
void %foo(float* %D, uint %E) {
define void @foo(float* %D, i32 %E) {
entry:
br label %no_exit
no_exit:
%indvar = phi uint [ 0, %entry ], [ %indvar.next, %no_exit ]
volatile store float 0.0, float* %D
%indvar.next = add uint %indvar, 1 ; <uint> [#uses=2]
%exitcond = seteq uint %indvar.next, %E ; <bool> [#uses=1]
br bool %exitcond, label %loopexit, label %no_exit
loopexit:
no_exit: ; preds = %no_exit, %entry
%indvar = phi i32 [ 0, %entry ], [ %indvar.next, %no_exit ] ; <i32> [#uses=1]
volatile store float 0.000000e+00, float* %D
%indvar.next = add i32 %indvar, 1 ; <i32> [#uses=2]
%exitcond = icmp eq i32 %indvar.next, %E ; <i1> [#uses=1]
br i1 %exitcond, label %loopexit, label %no_exit
loopexit: ; preds = %no_exit
ret void
}

View File

@ -1,22 +1,23 @@
; Check that the index of 'P[outer]' is pulled out of the loop.
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | \
; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | \
; RUN: not grep {getelementptr.*%outer.*%INDVAR}
declare bool %pred()
declare int %foo()
declare i1 @pred()
void %test([10000 x int]* %P) {
%outer = call int %foo()
declare i32 @foo()
define void @test([10000 x i32]* %P) {
; <label>:0
%outer = call i32 @foo( ) ; <i32> [#uses=1]
br label %Loop
Loop:
%INDVAR = phi int [0, %0], [%INDVAR2, %Loop]
%STRRED = getelementptr [10000 x int]* %P, int %outer, int %INDVAR
store int 0, int* %STRRED
%INDVAR2 = add int %INDVAR, 1
%cond = call bool %pred()
br bool %cond, label %Loop, label %Out
Out:
Loop: ; preds = %Loop, %0
%INDVAR = phi i32 [ 0, %0 ], [ %INDVAR2, %Loop ] ; <i32> [#uses=2]
%STRRED = getelementptr [10000 x i32]* %P, i32 %outer, i32 %INDVAR ; <i32*> [#uses=1]
store i32 0, i32* %STRRED
%INDVAR2 = add i32 %INDVAR, 1 ; <i32> [#uses=1]
%cond = call i1 @pred( ) ; <i1> [#uses=1]
br i1 %cond, label %Loop, label %Out
Out: ; preds = %Loop
ret void
}

View File

@ -1,20 +1,20 @@
; Check that the index of 'P[outer]' is pulled out of the loop.
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | \
; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | \
; RUN: not grep {getelementptr.*%outer.*%INDVAR}
declare bool %pred()
declare i1 @pred()
void %test([10000 x int]* %P, int %outer) {
define void @test([10000 x i32]* %P, i32 %outer) {
; <label>:0
br label %Loop
Loop:
%INDVAR = phi int [0, %0], [%INDVAR2, %Loop]
%STRRED = getelementptr [10000 x int]* %P, int %outer, int %INDVAR
store int 0, int* %STRRED
%INDVAR2 = add int %INDVAR, 1
%cond = call bool %pred()
br bool %cond, label %Loop, label %Out
Out:
Loop: ; preds = %Loop, %0
%INDVAR = phi i32 [ 0, %0 ], [ %INDVAR2, %Loop ] ; <i32> [#uses=2]
%STRRED = getelementptr [10000 x i32]* %P, i32 %outer, i32 %INDVAR ; <i32*> [#uses=1]
store i32 0, i32* %STRRED
%INDVAR2 = add i32 %INDVAR, 1 ; <i32> [#uses=1]
%cond = call i1 @pred( ) ; <i1> [#uses=1]
br i1 %cond, label %Loop, label %Out
Out: ; preds = %Loop
ret void
}

View File

@ -1,56 +1,49 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | not grep mul
; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | not grep mul
; Make sure we don't get a multiply by 6 in this loop.
int %foo(int %A, int %B, int %C, int %D) {
define i32 @foo(i32 %A, i32 %B, i32 %C, i32 %D) {
entry:
%tmp.5 = setgt int %C, 0 ; <bool> [#uses=1]
%tmp.25 = and int %A, 1 ; <int> [#uses=1]
%tmp.5 = icmp sgt i32 %C, 0 ; <i1> [#uses=1]
%tmp.25 = and i32 %A, 1 ; <i32> [#uses=1]
br label %loopentry.1
loopentry.1: ; preds = %loopexit.1, %entry
%indvar20 = phi uint [ 0, %entry ], [ %indvar.next21, %loopexit.1 ] ; <uint> [#uses=2]
%k.1 = phi int [ 0, %entry ], [ %k.1.3, %loopexit.1 ] ; <int> [#uses=2]
br bool %tmp.5, label %no_exit.1.preheader, label %loopexit.1
%indvar20 = phi i32 [ 0, %entry ], [ %indvar.next21, %loopexit.1 ] ; <i32> [#uses=2]
%k.1 = phi i32 [ 0, %entry ], [ %k.1.3, %loopexit.1 ] ; <i32> [#uses=2]
br i1 %tmp.5, label %no_exit.1.preheader, label %loopexit.1
no_exit.1.preheader: ; preds = %loopentry.1
%i.0.0 = cast uint %indvar20 to int ; <int> [#uses=1]
%tmp.9 = mul int %i.0.0, 6 ; <int> [#uses=1]
%i.0.0 = bitcast i32 %indvar20 to i32 ; <i32> [#uses=1]
%tmp.9 = mul i32 %i.0.0, 6 ; <i32> [#uses=1]
br label %no_exit.1.outer
no_exit.1.outer: ; preds = %cond_true, %no_exit.1.preheader
%k.1.2.ph = phi int [ %k.1, %no_exit.1.preheader ], [ %k.09, %cond_true ] ; <int> [#uses=2]
%j.1.2.ph = phi int [ 0, %no_exit.1.preheader ], [ %inc.1, %cond_true ] ; <int> [#uses=1]
%k.1.2.ph = phi i32 [ %k.1, %no_exit.1.preheader ], [ %k.09, %cond_true ] ; <i32> [#uses=2]
%j.1.2.ph = phi i32 [ 0, %no_exit.1.preheader ], [ %inc.1, %cond_true ] ; <i32> [#uses=1]
br label %no_exit.1
no_exit.1: ; preds = %cond_continue, %no_exit.1.outer
%indvar.ui = phi uint [ 0, %no_exit.1.outer ], [ %indvar.next, %cond_continue ] ; <uint> [#uses=2]
%indvar = cast uint %indvar.ui to int ; <int> [#uses=1]
%j.1.2 = add int %indvar, %j.1.2.ph ; <int> [#uses=2]
%tmp.11 = add int %j.1.2, %tmp.9 ; <int> [#uses=1]
%tmp.12 = cast int %tmp.11 to ubyte ; <ubyte> [#uses=1]
%tmp.13 = shl int %D, ubyte %tmp.12 ; <int> [#uses=2]
%tmp.15 = seteq int %tmp.13, %B ; <bool> [#uses=1]
%inc.1 = add int %j.1.2, 1 ; <int> [#uses=3]
br bool %tmp.15, label %cond_true, label %cond_continue
%indvar.ui = phi i32 [ 0, %no_exit.1.outer ], [ %indvar.next, %cond_continue ] ; <i32> [#uses=2]
%indvar = bitcast i32 %indvar.ui to i32 ; <i32> [#uses=1]
%j.1.2 = add i32 %indvar, %j.1.2.ph ; <i32> [#uses=2]
%tmp.11 = add i32 %j.1.2, %tmp.9 ; <i32> [#uses=1]
%tmp.12 = trunc i32 %tmp.11 to i8 ; <i8> [#uses=1]
%shift.upgrd.1 = zext i8 %tmp.12 to i32 ; <i32> [#uses=1]
%tmp.13 = shl i32 %D, %shift.upgrd.1 ; <i32> [#uses=2]
%tmp.15 = icmp eq i32 %tmp.13, %B ; <i1> [#uses=1]
%inc.1 = add i32 %j.1.2, 1 ; <i32> [#uses=3]
br i1 %tmp.15, label %cond_true, label %cond_continue
cond_true: ; preds = %no_exit.1
%tmp.26 = and int %tmp.25, %tmp.13 ; <int> [#uses=1]
%k.09 = add int %tmp.26, %k.1.2.ph ; <int> [#uses=2]
%tmp.517 = setlt int %inc.1, %C ; <bool> [#uses=1]
br bool %tmp.517, label %no_exit.1.outer, label %loopexit.1
%tmp.26 = and i32 %tmp.25, %tmp.13 ; <i32> [#uses=1]
%k.09 = add i32 %tmp.26, %k.1.2.ph ; <i32> [#uses=2]
%tmp.517 = icmp slt i32 %inc.1, %C ; <i1> [#uses=1]
br i1 %tmp.517, label %no_exit.1.outer, label %loopexit.1
cond_continue: ; preds = %no_exit.1
%tmp.519 = setlt int %inc.1, %C ; <bool> [#uses=1]
%indvar.next = add uint %indvar.ui, 1 ; <uint> [#uses=1]
br bool %tmp.519, label %no_exit.1, label %loopexit.1
%tmp.519 = icmp slt i32 %inc.1, %C ; <i1> [#uses=1]
%indvar.next = add i32 %indvar.ui, 1 ; <i32> [#uses=1]
br i1 %tmp.519, label %no_exit.1, label %loopexit.1
loopexit.1: ; preds = %cond_continue, %cond_true, %loopentry.1
%k.1.3 = phi int [ %k.1, %loopentry.1 ], [ %k.09, %cond_true ], [ %k.1.2.ph, %cond_continue ] ; <int> [#uses=2]
%indvar.next21 = add uint %indvar20, 1 ; <uint> [#uses=2]
%exitcond = seteq uint %indvar.next21, 4 ; <bool> [#uses=1]
br bool %exitcond, label %loopexit.0, label %loopentry.1
%k.1.3 = phi i32 [ %k.1, %loopentry.1 ], [ %k.09, %cond_true ], [ %k.1.2.ph, %cond_continue ] ; <i32> [#uses=2]
%indvar.next21 = add i32 %indvar20, 1 ; <i32> [#uses=2]
%exitcond = icmp eq i32 %indvar.next21, 4 ; <i1> [#uses=1]
br i1 %exitcond, label %loopexit.0, label %loopentry.1
loopexit.0: ; preds = %loopexit.1
ret int %k.1.3
ret i32 %k.1.3
}

View File

@ -1,22 +1,24 @@
; Check that this test makes INDVAR and related stuff dead, because P[indvar]
; gets reduced, making INDVAR dead.
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | not grep INDVAR
; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | not grep INDVAR
declare bool %pred()
declare int %getidx()
declare i1 @pred()
void %test([10000 x int]* %P) {
declare i32 @getidx()
define void @test([10000 x i32]* %P) {
; <label>:0
br label %Loop
Loop:
%INDVAR = phi int [0, %0], [%INDVAR2, %Loop]
%idx = call int %getidx()
%STRRED = getelementptr [10000 x int]* %P, int %INDVAR, int %idx
store int 0, int* %STRRED
%INDVAR2 = add int %INDVAR, 1
%cond = call bool %pred()
br bool %cond, label %Loop, label %Out
Out:
Loop: ; preds = %Loop, %0
%INDVAR = phi i32 [ 0, %0 ], [ %INDVAR2, %Loop ] ; <i32> [#uses=2]
%idx = call i32 @getidx( ) ; <i32> [#uses=1]
%STRRED = getelementptr [10000 x i32]* %P, i32 %INDVAR, i32 %idx ; <i32*> [#uses=1]
store i32 0, i32* %STRRED
%INDVAR2 = add i32 %INDVAR, 1 ; <i32> [#uses=1]
%cond = call i1 @pred( ) ; <i1> [#uses=1]
br i1 %cond, label %Loop, label %Out
Out: ; preds = %Loop
ret void
}

View File

@ -1,29 +1,28 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce -disable-output
; RUN: llvm-as < %s | opt -loop-reduce -disable-output
; LSR should not crash on this.
fastcc void %loadloop() {
define fastcc void @loadloop() {
entry:
switch sbyte 0, label %shortcirc_next [
sbyte 32, label %loopexit.2
sbyte 59, label %loopexit.2
switch i8 0, label %shortcirc_next [
i8 32, label %loopexit.2
i8 59, label %loopexit.2
]
shortcirc_next: ; preds = %no_exit.2, %entry
%indvar37 = phi uint [ 0, %entry ], [ %indvar.next38, %no_exit.2 ] ; <uint> [#uses=3]
%wp.2.4 = getelementptr sbyte* null, uint %indvar37 ; <sbyte*> [#uses=1]
br bool false, label %loopexit.2, label %no_exit.2
%indvar37 = phi i32 [ 0, %entry ], [ %indvar.next38, %no_exit.2 ] ; <i32> [#uses=3]
%gep.upgrd.1 = zext i32 %indvar37 to i64 ; <i64> [#uses=1]
%wp.2.4 = getelementptr i8* null, i64 %gep.upgrd.1 ; <i8*> [#uses=1]
br i1 false, label %loopexit.2, label %no_exit.2
no_exit.2: ; preds = %shortcirc_next
%wp.2.4.rec = cast uint %indvar37 to int ; <int> [#uses=1]
%inc.1.rec = add int %wp.2.4.rec, 1 ; <int> [#uses=1]
%inc.1 = getelementptr sbyte* null, int %inc.1.rec ; <sbyte*> [#uses=2]
%indvar.next38 = add uint %indvar37, 1 ; <uint> [#uses=1]
switch sbyte 0, label %shortcirc_next [
sbyte 32, label %loopexit.2
sbyte 59, label %loopexit.2
%wp.2.4.rec = bitcast i32 %indvar37 to i32 ; <i32> [#uses=1]
%inc.1.rec = add i32 %wp.2.4.rec, 1 ; <i32> [#uses=1]
%inc.1 = getelementptr i8* null, i32 %inc.1.rec ; <i8*> [#uses=2]
%indvar.next38 = add i32 %indvar37, 1 ; <i32> [#uses=1]
switch i8 0, label %shortcirc_next [
i8 32, label %loopexit.2
i8 59, label %loopexit.2
]
loopexit.2: ; preds = %no_exit.2, %no_exit.2, %shortcirc_next, %entry, %entry
%wp.2.7 = phi sbyte* [ null, %entry ], [ null, %entry ], [ %wp.2.4, %shortcirc_next ], [ %inc.1, %no_exit.2 ], [ %inc.1, %no_exit.2 ] ; <sbyte*> [#uses=0]
%wp.2.7 = phi i8* [ null, %entry ], [ null, %entry ], [ %wp.2.4, %shortcirc_next ], [ %inc.1, %no_exit.2 ], [ %inc.1, %no_exit.2 ] ; <i8*> [#uses=0]
ret void
}

View File

@ -1,4 +1,4 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | grep phi | count 1
; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | grep phi | count 1
; This should only result in one PHI node!
@ -7,22 +7,21 @@
; *D++ = F;
; }
void %foo(double* %D, double* %E, double %F) {
define void @foo(double* %D, double* %E, double %F) {
entry:
%tmp.24 = seteq double* %D, %E ; <bool> [#uses=1]
br bool %tmp.24, label %return, label %no_exit
%tmp.24 = icmp eq double* %D, %E ; <i1> [#uses=1]
br i1 %tmp.24, label %return, label %no_exit
no_exit: ; preds = %no_exit, %entry
%indvar = phi uint [ 0, %entry ], [ %indvar.next, %no_exit ] ; <uint> [#uses=3]
%D_addr.0.0.rec = cast uint %indvar to int ; <int> [#uses=1]
%D_addr.0.0 = getelementptr double* %D, int %D_addr.0.0.rec ; <double*> [#uses=1]
%inc.rec = add int %D_addr.0.0.rec, 1 ; <int> [#uses=1]
%inc = getelementptr double* %D, int %inc.rec ; <double*> [#uses=1]
%indvar = phi i32 [ 0, %entry ], [ %indvar.next, %no_exit ] ; <i32> [#uses=2]
%D_addr.0.0.rec = bitcast i32 %indvar to i32 ; <i32> [#uses=2]
%D_addr.0.0 = getelementptr double* %D, i32 %D_addr.0.0.rec ; <double*> [#uses=1]
%inc.rec = add i32 %D_addr.0.0.rec, 1 ; <i32> [#uses=1]
%inc = getelementptr double* %D, i32 %inc.rec ; <double*> [#uses=1]
store double %F, double* %D_addr.0.0
%tmp.2 = seteq double* %inc, %E ; <bool> [#uses=1]
%indvar.next = add uint %indvar, 1 ; <uint> [#uses=1]
br bool %tmp.2, label %return, label %no_exit
%tmp.2 = icmp eq double* %inc, %E ; <i1> [#uses=1]
%indvar.next = add i32 %indvar, 1 ; <i32> [#uses=1]
br i1 %tmp.2, label %return, label %no_exit
return: ; preds = %no_exit, %entry
ret void
}

View File

@ -1,19 +1,19 @@
; Check that this test makes INDVAR and related stuff dead.
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | not grep INDVAR
; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | not grep INDVAR
declare bool %pred()
declare i1 @pred()
void %test(int* %P) {
define void @test(i32* %P) {
; <label>:0
br label %Loop
Loop:
%INDVAR = phi int [0, %0], [%INDVAR2, %Loop]
%STRRED = getelementptr int* %P, int %INDVAR
store int 0, int* %STRRED
%INDVAR2 = add int %INDVAR, 1
%cond = call bool %pred()
br bool %cond, label %Loop, label %Out
Out:
Loop: ; preds = %Loop, %0
%INDVAR = phi i32 [ 0, %0 ], [ %INDVAR2, %Loop ] ; <i32> [#uses=2]
%STRRED = getelementptr i32* %P, i32 %INDVAR ; <i32*> [#uses=1]
store i32 0, i32* %STRRED
%INDVAR2 = add i32 %INDVAR, 1 ; <i32> [#uses=1]
%cond = call i1 @pred( ) ; <i1> [#uses=1]
br i1 %cond, label %Loop, label %Out
Out: ; preds = %Loop
ret void
}

View File

@ -1,28 +1,27 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | grep mul | count 1
; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | grep mul | count 1
; LSR should not make two copies of the Q*L expression in the preheader!
sbyte %test(sbyte* %A, sbyte* %B, int %L, int %Q, int %N.s) {
define i8 @test(i8* %A, i8* %B, i32 %L, i32 %Q, i32 %N.s) {
entry:
%tmp.6 = mul int %Q, %L ; <int> [#uses=1]
%N = cast int %N.s to uint ; <uint> [#uses=1]
%tmp.6 = mul i32 %Q, %L ; <i32> [#uses=1]
%N = bitcast i32 %N.s to i32 ; <i32> [#uses=1]
br label %no_exit
no_exit: ; preds = %no_exit, %no_exit.preheader
%indvar.ui = phi uint [ 0, %entry], [ %indvar.next, %no_exit ] ; <uint> [#uses=2]
%Sum.0.0 = phi sbyte [ 0, %entry], [ %tmp.21, %no_exit ] ; <sbyte> [#uses=1]
%indvar = cast uint %indvar.ui to int ; <int> [#uses=1]
%N_addr.0.0 = sub int %N.s, %indvar ; <int> [#uses=1]
%tmp.8 = add int %N_addr.0.0, %tmp.6 ; <int> [#uses=2]
%tmp.9 = getelementptr sbyte* %A, int %tmp.8 ; <sbyte*> [#uses=1]
%tmp.10 = load sbyte* %tmp.9 ; <sbyte> [#uses=1]
%tmp.17 = getelementptr sbyte* %B, int %tmp.8 ; <sbyte*> [#uses=1]
%tmp.18 = load sbyte* %tmp.17 ; <sbyte> [#uses=1]
%tmp.19 = sub sbyte %tmp.10, %tmp.18 ; <sbyte> [#uses=1]
%tmp.21 = add sbyte %tmp.19, %Sum.0.0 ; <sbyte> [#uses=2]
%indvar.next = add uint %indvar.ui, 1 ; <uint> [#uses=2]
%exitcond = seteq uint %indvar.next, %N ; <bool> [#uses=1]
br bool %exitcond, label %loopexit, label %no_exit
loopexit:
ret sbyte %tmp.21
no_exit: ; preds = %no_exit, %entry
%indvar.ui = phi i32 [ 0, %entry ], [ %indvar.next, %no_exit ] ; <i32> [#uses=2]
%Sum.0.0 = phi i8 [ 0, %entry ], [ %tmp.21, %no_exit ] ; <i8> [#uses=1]
%indvar = bitcast i32 %indvar.ui to i32 ; <i32> [#uses=1]
%N_addr.0.0 = sub i32 %N.s, %indvar ; <i32> [#uses=1]
%tmp.8 = add i32 %N_addr.0.0, %tmp.6 ; <i32> [#uses=2]
%tmp.9 = getelementptr i8* %A, i32 %tmp.8 ; <i8*> [#uses=1]
%tmp.10 = load i8* %tmp.9 ; <i8> [#uses=1]
%tmp.17 = getelementptr i8* %B, i32 %tmp.8 ; <i8*> [#uses=1]
%tmp.18 = load i8* %tmp.17 ; <i8> [#uses=1]
%tmp.19 = sub i8 %tmp.10, %tmp.18 ; <i8> [#uses=1]
%tmp.21 = add i8 %tmp.19, %Sum.0.0 ; <i8> [#uses=2]
%indvar.next = add i32 %indvar.ui, 1 ; <i32> [#uses=2]
%exitcond = icmp eq i32 %indvar.next, %N ; <i1> [#uses=1]
br i1 %exitcond, label %loopexit, label %no_exit
loopexit: ; preds = %no_exit
ret i8 %tmp.21
}

View File

@ -1,24 +1,24 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | grep phi | count 1
; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | grep phi | count 1
; This testcase should have ONE stride 18 indvar, the other use should have a
; loop invariant value (B) added to it inside of the loop, instead of having
; a whole indvar based on B for it.
declare bool %cond(uint)
declare i1 @cond(i32)
void %test(uint %B) {
define void @test(i32 %B) {
; <label>:0
br label %Loop
Loop:
%IV = phi uint [0, %0], [%IVn, %Loop]
%C = mul uint %IV, 18
%D = mul uint %IV, 18
%E = add uint %D, %B
%cnd = call bool %cond(uint %E)
call bool %cond(uint %C)
%IVn = add uint %IV, 1
br bool %cnd, label %Loop, label %Out
Out:
Loop: ; preds = %Loop, %0
%IV = phi i32 [ 0, %0 ], [ %IVn, %Loop ] ; <i32> [#uses=3]
%C = mul i32 %IV, 18 ; <i32> [#uses=1]
%D = mul i32 %IV, 18 ; <i32> [#uses=1]
%E = add i32 %D, %B ; <i32> [#uses=1]
%cnd = call i1 @cond( i32 %E ) ; <i1> [#uses=1]
call i1 @cond( i32 %C ) ; <i1>:1 [#uses=0]
%IVn = add i32 %IV, 1 ; <i32> [#uses=1]
br i1 %cnd, label %Loop, label %Out
Out: ; preds = %Loop
ret void
}

View File

@ -1,4 +1,4 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | \
; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | \
; RUN: grep {add i32 %iv.*inc, 1}
;
; Make sure that the use of the IV outside of the loop (the store) uses the
@ -7,23 +7,23 @@
; around for the duration of the loop, adding a copy and an extra register
; to the loop.
declare bool %pred(int %X)
declare i1 @pred(i32)
void %test([700 x int]* %nbeaux_.0__558, int* %i_.16574) {
define void @test([700 x i32]* %nbeaux_.0__558, i32* %i_.16574) {
then.0:
br label %no_exit.2
no_exit.2: ; preds = %no_exit.2, %then.0
%indvar630.ui = phi uint [ 0, %then.0 ], [ %indvar.next631, %no_exit.2 ] ; <uint> [#uses=3]
%indvar630 = cast uint %indvar630.ui to int ; <int> [#uses=1]
%tmp.38 = getelementptr [700 x int]* %nbeaux_.0__558, int 0, uint %indvar630.ui ; <int*> [#uses=1]
store int 0, int* %tmp.38
%inc.2 = add int %indvar630, 2 ; <int> [#uses=2]
%tmp.34 = call bool %pred(int %indvar630)
%indvar.next631 = add uint %indvar630.ui, 1 ; <uint> [#uses=1]
br bool %tmp.34, label %no_exit.2, label %loopexit.2.loopexit
loopexit.2.loopexit: ; preds = %no_exit.2
store int %inc.2, int* %i_.16574
ret void
br label %no_exit.2
no_exit.2: ; preds = %no_exit.2, %then.0
%indvar630.ui = phi i32 [ 0, %then.0 ], [ %indvar.next631, %no_exit.2 ] ; <i32> [#uses=3]
%indvar630 = bitcast i32 %indvar630.ui to i32 ; <i32> [#uses=2]
%gep.upgrd.1 = zext i32 %indvar630.ui to i64 ; <i64> [#uses=1]
%tmp.38 = getelementptr [700 x i32]* %nbeaux_.0__558, i32 0, i64 %gep.upgrd.1 ; <i32*> [#uses=1]
store i32 0, i32* %tmp.38
%inc.2 = add i32 %indvar630, 2 ; <i32> [#uses=1]
%tmp.34 = call i1 @pred( i32 %indvar630 ) ; <i1> [#uses=1]
%indvar.next631 = add i32 %indvar630.ui, 1 ; <i32> [#uses=1]
br i1 %tmp.34, label %no_exit.2, label %loopexit.2.loopexit
loopexit.2.loopexit: ; preds = %no_exit.2
store i32 %inc.2, i32* %i_.16574
ret void
}

View File

@ -1,49 +1,41 @@
; Base should not be i*3, it should be i*2.
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | \
; RUN: not grep {mul.*%i, 3}
; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | \
; RUN: not grep {mul.*%i, 3}
; Indvar should not start at zero:
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | \
; RUN: not grep {phi uint .* 0}
; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | \
; RUN: not grep {phi i32 .* 0}
; END.
; mul uint %i, 3
; ModuleID = 't.bc'
target datalayout = "e-p:32:32"
target endian = little
target pointersize = 32
target triple = "i686-apple-darwin8"
%flags2 = external global [8193 x sbyte], align 32 ; <[8193 x sbyte]*> [#uses=1]
@flags2 = external global [8193 x i8], align 32 ; <[8193 x i8]*> [#uses=1]
implementation ; Functions:
void %foo(int %k, int %i.s) {
define void @foo(i32 %k, i32 %i.s) {
entry:
%i = cast int %i.s to uint ; <uint> [#uses=2]
%k_addr.012 = shl int %i.s, ubyte 1 ; <int> [#uses=1]
%tmp14 = setgt int %k_addr.012, 8192 ; <bool> [#uses=1]
br bool %tmp14, label %return, label %bb.preheader
%i = bitcast i32 %i.s to i32 ; <i32> [#uses=2]
%k_addr.012 = shl i32 %i.s, 1 ; <i32> [#uses=1]
%tmp14 = icmp sgt i32 %k_addr.012, 8192 ; <i1> [#uses=1]
br i1 %tmp14, label %return, label %bb.preheader
bb.preheader: ; preds = %entry
%tmp. = shl uint %i, ubyte 1 ; <uint> [#uses=1]
%tmp. = shl i32 %i, 1 ; <i32> [#uses=1]
br label %bb
bb: ; preds = %bb, %bb.preheader
%indvar = phi uint [ %indvar.next, %bb ], [ 0, %bb.preheader ] ; <uint> [#uses=2]
%tmp.15 = mul uint %indvar, %i ; <uint> [#uses=1]
%tmp.16 = add uint %tmp.15, %tmp. ; <uint> [#uses=2]
%k_addr.0.0 = cast uint %tmp.16 to int ; <int> [#uses=1]
%tmp = getelementptr [8193 x sbyte]* %flags2, int 0, uint %tmp.16 ; <sbyte*> [#uses=1]
store sbyte 0, sbyte* %tmp
%k_addr.0 = add int %k_addr.0.0, %i.s ; <int> [#uses=1]
%tmp = setgt int %k_addr.0, 8192 ; <bool> [#uses=1]
%indvar.next = add uint %indvar, 1 ; <uint> [#uses=1]
br bool %tmp, label %return.loopexit, label %bb
%indvar = phi i32 [ %indvar.next, %bb ], [ 0, %bb.preheader ] ; <i32> [#uses=2]
%tmp.15 = mul i32 %indvar, %i ; <i32> [#uses=1]
%tmp.16 = add i32 %tmp.15, %tmp. ; <i32> [#uses=2]
%k_addr.0.0 = bitcast i32 %tmp.16 to i32 ; <i32> [#uses=1]
%gep.upgrd.1 = zext i32 %tmp.16 to i64 ; <i64> [#uses=1]
%tmp = getelementptr [8193 x i8]* @flags2, i32 0, i64 %gep.upgrd.1 ; <i8*> [#uses=1]
store i8 0, i8* %tmp
%k_addr.0 = add i32 %k_addr.0.0, %i.s ; <i32> [#uses=1]
%tmp.upgrd.2 = icmp sgt i32 %k_addr.0, 8192 ; <i1> [#uses=1]
%indvar.next = add i32 %indvar, 1 ; <i32> [#uses=1]
br i1 %tmp.upgrd.2, label %return.loopexit, label %bb
return.loopexit: ; preds = %bb
br label %return
return: ; preds = %return.loopexit, %entry
ret void
}

View File

@ -1,17 +1,18 @@
; Check that variable strides are reduced to adds instead of multiplies.
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | not grep mul
; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | not grep mul
declare bool %pred(int)
declare i1 @pred(i32)
void %test([10000 x int]* %P, int %STRIDE) {
define void @test([10000 x i32]* %P, i32 %STRIDE) {
; <label>:0
br label %Loop
Loop:
%INDVAR = phi int [0, %0], [%INDVAR2, %Loop]
%Idx = mul int %INDVAR, %STRIDE
%cond = call bool %pred(int %Idx)
%INDVAR2 = add int %INDVAR, 1
br bool %cond, label %Loop, label %Out
Out:
Loop: ; preds = %Loop, %0
%INDVAR = phi i32 [ 0, %0 ], [ %INDVAR2, %Loop ] ; <i32> [#uses=2]
%Idx = mul i32 %INDVAR, %STRIDE ; <i32> [#uses=1]
%cond = call i1 @pred( i32 %Idx ) ; <i1> [#uses=1]
%INDVAR2 = add i32 %INDVAR, 1 ; <i32> [#uses=1]
br i1 %cond, label %Loop, label %Out
Out: ; preds = %Loop
ret void
}

View File

@ -1,15 +1,14 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-unroll -disable-output
; RUN: llvm-as < %s | opt -loop-unroll -disable-output
int %main() {
define i32 @main() {
entry:
br label %no_exit
no_exit: ; preds = %entry, %no_exit
%indvar = phi uint [ 0, %entry ], [ %indvar.next, %no_exit ] ; <uint> [#uses=1]
%indvar.next = add uint %indvar, 1 ; <uint> [#uses=2]
%exitcond = setne uint %indvar.next, 2147483648 ; <bool> [#uses=1]
br bool %exitcond, label %no_exit, label %loopexit
loopexit: ; preds = %no_exit
ret int 0
br label %no_exit
no_exit: ; preds = %no_exit, %entry
%indvar = phi i32 [ 0, %entry ], [ %indvar.next, %no_exit ] ; <i32> [#uses=1]
%indvar.next = add i32 %indvar, 1 ; <i32> [#uses=2]
%exitcond = icmp ne i32 %indvar.next, -2147483648 ; <i1> [#uses=1]
br i1 %exitcond, label %no_exit, label %loopexit
loopexit: ; preds = %no_exit
ret i32 0
}

View File

@ -1,29 +1,22 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-unroll -loopsimplify -disable-output
; RUN: llvm-as < %s | opt -loop-unroll -loopsimplify -disable-output
implementation ; Functions:
void %print_board() {
define void @print_board() {
entry:
br label %no_exit.1
no_exit.1: ; preds = %cond_false.2, %entry
br label %no_exit.2
no_exit.2: ; preds = %no_exit.2, %no_exit.1
%indvar1 = phi uint [ 0, %no_exit.1 ], [ %indvar.next2, %no_exit.2 ] ; <uint> [#uses=1]
%indvar.next2 = add uint %indvar1, 1 ; <uint> [#uses=2]
%exitcond3 = setne uint %indvar.next2, 7 ; <bool> [#uses=1]
br bool %exitcond3, label %no_exit.2, label %loopexit.2
%indvar1 = phi i32 [ 0, %no_exit.1 ], [ %indvar.next2, %no_exit.2 ] ; <i32> [#uses=1]
%indvar.next2 = add i32 %indvar1, 1 ; <i32> [#uses=2]
%exitcond3 = icmp ne i32 %indvar.next2, 7 ; <i1> [#uses=1]
br i1 %exitcond3, label %no_exit.2, label %loopexit.2
loopexit.2: ; preds = %no_exit.2
br bool false, label %cond_true.2, label %cond_false.2
br i1 false, label %cond_true.2, label %cond_false.2
cond_true.2: ; preds = %loopexit.2
ret void
cond_false.2: ; preds = %loopexit.2
br bool false, label %no_exit.1, label %loopexit.1
br i1 false, label %no_exit.1, label %loopexit.1
loopexit.1: ; preds = %cond_false.2
ret void
}

View File

@ -1,18 +1,16 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-unroll | llvm-dis | grep bb72.2
; RUN: llvm-as < %s | opt -loop-unroll | llvm-dis | grep bb72.2
void %vorbis_encode_noisebias_setup() {
define void @vorbis_encode_noisebias_setup() {
entry:
br label %cond_true.outer
cond_true.outer:
%indvar1.ph = phi uint [ 0, %entry ], [ %indvar.next2, %bb72 ]
cond_true.outer: ; preds = %bb72, %entry
%indvar1.ph = phi i32 [ 0, %entry ], [ %indvar.next2, %bb72 ] ; <i32> [#uses=1]
br label %bb72
bb72:
%indvar.next2 = add uint %indvar1.ph, 1
%exitcond3 = seteq uint %indvar.next2, 3
br bool %exitcond3, label %cond_true138, label %cond_true.outer
cond_true138:
bb72: ; preds = %cond_true.outer
%indvar.next2 = add i32 %indvar1.ph, 1 ; <i32> [#uses=2]
%exitcond3 = icmp eq i32 %indvar.next2, 3 ; <i1> [#uses=1]
br i1 %exitcond3, label %cond_true138, label %cond_true.outer
cond_true138: ; preds = %bb72
ret void
}

View File

@ -1,18 +1,17 @@
; PR 1334
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-unroll -disable-output
; RUN: llvm-as < %s | opt -loop-unroll -disable-output
void @sal__math_float_manipulator_7__math__joint_array_dcv_ops__Omultiply__3([6 x float]* %agg.result) {
define void @sal__math_float_manipulator_7__math__joint_array_dcv_ops__Omultiply__3([6 x float]* %agg.result) {
entry:
%tmp282911 = zext i8 0 to i32 ; <i32> [#uses=1]
br label %cond_next
cond_next: ; preds = %cond_next, %entry
%indvar = phi i8 [ 0, %entry ], [ %indvar.next, %cond_next ] ; <i8> [#uses=1]
%indvar.next = add i8 %indvar, 1 ; <i8> [#uses=2]
%exitcond = icmp eq i8 %indvar.next, 7 ; <i1> [#uses=1]
br i1 %exitcond, label %bb27, label %cond_next
bb27: ; preds = %cond_next
%tmp282911.lcssa = phi i32 [ %tmp282911, %cond_next ] ; <i32> [#uses=0]
ret void
}

View File

@ -1,42 +1,32 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-unswitch -disable-output
; RUN: llvm-as < %s | opt -loop-unswitch -disable-output
void %sort_Eq(int * %S2) {
define void @sort_Eq(i32* %S2) {
entry:
br bool false, label %list_Length.exit, label %cond_true.i
br i1 false, label %list_Length.exit, label %cond_true.i
cond_true.i: ; preds = %entry
ret void
list_Length.exit: ; preds = %entry
br bool false, label %list_Length.exit9, label %cond_true.i5
br i1 false, label %list_Length.exit9, label %cond_true.i5
cond_true.i5: ; preds = %list_Length.exit
ret void
list_Length.exit9: ; preds = %list_Length.exit
br bool false, label %bb78, label %return
br i1 false, label %bb78, label %return
bb44: ; preds = %bb78, %cond_next68
br bool %tmp49.not, label %bb62, label %bb62.loopexit
br i1 %tmp49.not, label %bb62, label %bb62.loopexit
bb62.loopexit: ; preds = %bb44
br label %bb62
bb62: ; preds = %bb62.loopexit, %bb44
br bool false, label %return.loopexit, label %cond_next68
br i1 false, label %return.loopexit, label %cond_next68
cond_next68: ; preds = %bb62
br bool false, label %return.loopexit, label %bb44
br i1 false, label %return.loopexit, label %bb44
bb78: ; preds = %list_Length.exit9
%tmp49.not = seteq int* %S2, null ; <bool> [#uses=1]
%tmp49.not = icmp eq i32* %S2, null ; <i1> [#uses=1]
br label %bb44
return.loopexit: ; preds = %cond_next68, %bb62
%retval.0.ph = phi uint [ 1, %cond_next68 ], [ 0, %bb62 ] ; <uint> [#uses=1]
%retval.0.ph = phi i32 [ 1, %cond_next68 ], [ 0, %bb62 ] ; <i32> [#uses=1]
br label %return
return: ; preds = %return.loopexit, %list_Length.exit9
%retval.0 = phi uint [ 0, %list_Length.exit9 ], [ %retval.0.ph, %return.loopexit ] ; <uint> [#uses=0]
%retval.0 = phi i32 [ 0, %list_Length.exit9 ], [ %retval.0.ph, %return.loopexit ] ; <i32> [#uses=0]
ret void
}

View File

@ -1,43 +1,34 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-unswitch -disable-output
; RUN: llvm-as < %s | opt -loop-unswitch -disable-output
%struct.BLEND_MAP = type { short, short, short, int, %struct.BLEND_MAP_ENTRY* }
%struct.BLEND_MAP_ENTRY = type { float, ubyte, { [5 x float], [4 x ubyte] } }
%struct.TPATTERN = type { ushort, ushort, ushort, int, float, float, float, %struct.WARP*, %struct.TPATTERN*, %struct.BLEND_MAP*, { %struct.anon, [4 x ubyte] } }
%struct.TURB = type { ushort, %struct.WARP*, [3 x double], int, float, float }
%struct.WARP = type { ushort, %struct.WARP* }
%struct.BLEND_MAP = type { i16, i16, i16, i32, %struct.BLEND_MAP_ENTRY* }
%struct.BLEND_MAP_ENTRY = type { float, i8, { [5 x float], [4 x i8] } }
%struct.TPATTERN = type { i16, i16, i16, i32, float, float, float, %struct.WARP*, %struct.TPATTERN*, %struct.BLEND_MAP*, { %struct.anon, [4 x i8] } }
%struct.TURB = type { i16, %struct.WARP*, [3 x double], i32, float, float }
%struct.WARP = type { i16, %struct.WARP* }
%struct.anon = type { float, [3 x double] }
implementation ; Functions:
void %Parse_Pattern() {
define void @Parse_Pattern() {
entry:
br label %bb1096.outer20
bb671: ; preds = %cond_true1099
br label %bb1096.outer23
bb1096.outer20.loopexit: ; preds = %cond_true1099
%Local_Turb.0.ph24.lcssa = phi %struct.TURB* [ %Local_Turb.0.ph24, %cond_true1099 ] ; <%struct.TURB*> [#uses=1]
br label %bb1096.outer20
bb1096.outer20: ; preds = %bb1096.outer20.loopexit, %entry
%Local_Turb.0.ph22 = phi %struct.TURB* [ undef, %entry ], [ %Local_Turb.0.ph24.lcssa, %bb1096.outer20.loopexit ] ; <%struct.TURB*> [#uses=1]
%tmp1098 = seteq int 0, 0 ; <bool> [#uses=1]
%tmp1098 = icmp eq i32 0, 0 ; <i1> [#uses=1]
br label %bb1096.outer23
bb1096.outer23: ; preds = %bb1096.outer20, %bb671
%Local_Turb.0.ph24 = phi %struct.TURB* [ %Local_Turb.0.ph22, %bb1096.outer20 ], [ null, %bb671 ] ; <%struct.TURB*> [#uses=2]
br label %bb1096
bb1096: ; preds = %cond_true1099, %bb1096.outer23
br bool %tmp1098, label %cond_true1099, label %bb1102
br i1 %tmp1098, label %cond_true1099, label %bb1102
cond_true1099: ; preds = %bb1096
switch int 0, label %bb1096.outer20.loopexit [
int 161, label %bb671
int 359, label %bb1096
switch i32 0, label %bb1096.outer20.loopexit [
i32 161, label %bb671
i32 359, label %bb1096
]
bb1102: ; preds = %bb1096
%Local_Turb.0.ph24.lcssa1 = phi %struct.TURB* [ %Local_Turb.0.ph24, %bb1096 ] ; <%struct.TURB*> [#uses=0]
ret void

View File

@ -1,31 +1,25 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-unswitch -disable-output
implementation ; Functions:
; RUN: llvm-as < %s | opt -loop-unswitch -disable-output
void %init_caller_save() {
define void @init_caller_save() {
entry:
br label %cond_true78
cond_next20: ; preds = %cond_true64
br label %bb31
bb31: ; preds = %cond_true64, %cond_true64, %cond_next20
%iftmp.29.1 = phi uint [ 0, %cond_next20 ], [ 0, %cond_true64 ], [ 0, %cond_true64 ] ; <uint> [#uses=0]
%iftmp.29.1 = phi i32 [ 0, %cond_next20 ], [ 0, %cond_true64 ], [ 0, %cond_true64 ] ; <i32> [#uses=0]
br label %bb54
bb54: ; preds = %cond_true78, %bb31
br bool false, label %bb75, label %cond_true64
br i1 false, label %bb75, label %cond_true64
cond_true64: ; preds = %bb54
switch int %i.0.0, label %cond_next20 [
int 17, label %bb31
int 18, label %bb31
switch i32 %i.0.0, label %cond_next20 [
i32 17, label %bb31
i32 18, label %bb31
]
bb75: ; preds = %bb54
%tmp74.0 = add int %i.0.0, 1 ; <int> [#uses=1]
%tmp74.0 = add i32 %i.0.0, 1 ; <i32> [#uses=1]
br label %cond_true78
cond_true78: ; preds = %bb75, %entry
%i.0.0 = phi int [ 0, %entry ], [ %tmp74.0, %bb75 ] ; <int> [#uses=2]
%i.0.0 = phi i32 [ 0, %entry ], [ %tmp74.0, %bb75 ] ; <i32> [#uses=2]
br label %bb54
}

View File

@ -1,5 +1,6 @@
; PR1333
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-unswitch -disable-output
; RUN: llvm-as < %s | opt -loop-unswitch -disable-output
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64"
target triple = "i686-pc-linux-gnu"
%struct.ada__streams__root_stream_type = type { %struct.ada__tags__dispatch_table* }
@ -7,26 +8,21 @@ target triple = "i686-pc-linux-gnu"
%struct.quotes__T173s = type { i8, %struct.quotes__T173s__T174s, [2 x [1 x double]], [2 x i16], i64, i8 }
%struct.quotes__T173s__T174s = type { i8, i8, i8, i16, i16, [2 x [1 x double]] }
void @quotes__write_quote() {
define void @quotes__write_quote() {
entry:
%tmp606.i = icmp eq i32 0, 0 ; <i1> [#uses=1]
br label %bb
bb: ; preds = %cond_next73, %bb, %entry
br i1 false, label %bb51, label %bb
bb51: ; preds = %cond_next73, %bb
br i1 %tmp606.i, label %quotes__bid_ask_depth_offset_matrices__get_price.exit, label %cond_true.i
cond_true.i: ; preds = %bb51
unreachable
quotes__bid_ask_depth_offset_matrices__get_price.exit: ; preds = %bb51
br i1 false, label %cond_next73, label %cond_true72
cond_true72: ; preds = %quotes__bid_ask_depth_offset_matrices__get_price.exit
unreachable
cond_next73: ; preds = %quotes__bid_ask_depth_offset_matrices__get_price.exit
br i1 false, label %bb, label %bb51
}

View File

@ -1,35 +1,31 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -loop-unswitch -disable-output
implementation ; Functions:
; RUN: llvm-as < %s | opt -loop-unswitch -disable-output
int %test(int* %A, bool %C) {
define i32 @test(i32* %A, i1 %C) {
entry:
br label %no_exit
no_exit: ; preds = %entry, %no_exit.backedge
%i.0.0 = phi uint [ 0, %entry ], [ %i.0.0.be, %no_exit.backedge ] ; <uint> [#uses=3]
%tmp.7 = getelementptr int* %A, uint %i.0.0 ; <int*> [#uses=4]
%tmp.13 = load int* %tmp.7 ; <int> [#uses=1]
%tmp.14 = add int %tmp.13, 1 ; <int> [#uses=1]
store int %tmp.14, int* %tmp.7
br bool %C, label %then, label %endif
no_exit: ; preds = %no_exit.backedge, %entry
%i.0.0 = phi i32 [ 0, %entry ], [ %i.0.0.be, %no_exit.backedge ] ; <i32> [#uses=3]
%gep.upgrd.1 = zext i32 %i.0.0 to i64 ; <i64> [#uses=1]
%tmp.7 = getelementptr i32* %A, i64 %gep.upgrd.1 ; <i32*> [#uses=4]
%tmp.13 = load i32* %tmp.7 ; <i32> [#uses=2]
%tmp.14 = add i32 %tmp.13, 1 ; <i32> [#uses=1]
store i32 %tmp.14, i32* %tmp.7
br i1 %C, label %then, label %endif
then: ; preds = %no_exit
%tmp.29 = load int* %tmp.7 ; <int> [#uses=1]
%tmp.30 = add int %tmp.29, 2 ; <int> [#uses=1]
store int %tmp.30, int* %tmp.7
%inc9 = add uint %i.0.0, 1 ; <uint> [#uses=2]
%tmp.112 = setlt uint %inc9, 100000 ; <bool> [#uses=1]
br bool %tmp.112, label %no_exit.backedge, label %return
no_exit.backedge: ; preds = %then, %endif
%i.0.0.be = phi uint [ %inc9, %then ], [ %inc, %endif ] ; <uint> [#uses=1]
%tmp.29 = load i32* %tmp.7 ; <i32> [#uses=1]
%tmp.30 = add i32 %tmp.29, 2 ; <i32> [#uses=1]
store i32 %tmp.30, i32* %tmp.7
%inc9 = add i32 %i.0.0, 1 ; <i32> [#uses=2]
%tmp.112 = icmp ult i32 %inc9, 100000 ; <i1> [#uses=1]
br i1 %tmp.112, label %no_exit.backedge, label %return
no_exit.backedge: ; preds = %endif, %then
%i.0.0.be = phi i32 [ %inc9, %then ], [ %inc, %endif ] ; <i32> [#uses=1]
br label %no_exit
endif: ; preds = %no_exit
%inc = add uint %i.0.0, 1 ; <uint> [#uses=2]
%tmp.1 = setlt uint %inc, 100000 ; <bool> [#uses=1]
br bool %tmp.1, label %no_exit.backedge, label %return
return: ; preds = %then, %endif
ret int %tmp.13
%inc = add i32 %i.0.0, 1 ; <i32> [#uses=2]
%tmp.1 = icmp ult i32 %inc, 100000 ; <i1> [#uses=1]
br i1 %tmp.1, label %no_exit.backedge, label %return
return: ; preds = %endif, %then
ret i32 %tmp.13
}

View File

@ -1,24 +1,22 @@
; This testcase was reduced from Shootout-C++/reversefile.cpp by bugpoint
; RUN: llvm-upgrade < %s | llvm-as | opt -lowerinvoke -disable-output
; RUN: llvm-as < %s | opt -lowerinvoke -disable-output
declare void %baz()
declare void @baz()
declare void %bar()
void %foo() {
then: ; preds = %entry
invoke void %baz( )
to label %invoke_cont.0 except label %try_catch
declare void @bar()
define void @foo() {
then:
invoke void @baz( )
to label %invoke_cont.0 unwind label %try_catch
invoke_cont.0: ; preds = %then
invoke void %bar( )
to label %try_exit except label %try_catch
try_catch: ; preds = %then, %invoke_cont.0
%__tmp.0 = phi int* [ null, %invoke_cont.0 ], [ null, %then ]
invoke void @bar( )
to label %try_exit unwind label %try_catch
try_catch: ; preds = %invoke_cont.0, %then
%__tmp.0 = phi i32* [ null, %invoke_cont.0 ], [ null, %then ] ; <i32*> [#uses=0]
ret void
try_exit: ; preds = %invoke_cont.0
ret void
}

View File

@ -1,16 +1,15 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -lowerinvoke -enable-correct-eh-support -disable-output
; RUN: llvm-as < %s | opt -lowerinvoke -enable-correct-eh-support -disable-output
void %_ZNKSt11__use_cacheISt16__numpunct_cacheIcEEclERKSt6locale() {
define void @_ZNKSt11__use_cacheISt16__numpunct_cacheIcEEclERKSt6locale() {
entry:
br bool false, label %then, label %UnifiedReturnBlock
br i1 false, label %then, label %UnifiedReturnBlock
then: ; preds = %entry
invoke void %_Znwj( )
invoke void @_Znwj( )
to label %UnifiedReturnBlock unwind label %UnifiedReturnBlock
UnifiedReturnBlock: ; preds = %entry, %then, %then
%UnifiedRetVal = phi int* [ null, %entry ], [ null, %then ], [ null, %then ]
UnifiedReturnBlock: ; preds = %then, %then, %entry
%UnifiedRetVal = phi i32* [ null, %entry ], [ null, %then ], [ null, %then ] ; <i32*> [#uses=0]
ret void
}
declare void %_Znwj()
declare void @_Znwj()

View File

@ -1,20 +1,17 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -lowerinvoke -enable-correct-eh-support -disable-output
; RUN: llvm-as < %s | opt -lowerinvoke -enable-correct-eh-support -disable-output
implementation ; Functions:
declare void @ll_listnext__listiterPtr()
declare void %ll_listnext__listiterPtr()
void %WorkTask.fn() {
define void @WorkTask.fn() {
block0:
invoke void %ll_listnext__listiterPtr( )
invoke void @ll_listnext__listiterPtr( )
to label %block9 unwind label %block8_exception_handling
block8_exception_handling: ; preds = %block0
ret void
block9: ; preds = %block0
%w_2690 = phi { int, int }* [ null, %block0 ] ; <{ int, int }*> [#uses=1]
%tmp.129 = getelementptr { int, int }* %w_2690, int 0, uint 1 ; <int*> [#uses=1]
%v2769 = load int* %tmp.129 ; <int> [#uses=0]
%w_2690 = phi { i32, i32 }* [ null, %block0 ] ; <{ i32, i32 }*> [#uses=1]
%tmp.129 = getelementptr { i32, i32 }* %w_2690, i32 0, i32 1 ; <i32*> [#uses=1]
%v2769 = load i32* %tmp.129 ; <i32> [#uses=0]
ret void
}

View File

@ -1,16 +1,15 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -lowerinvoke -enable-correct-eh-support -disable-output
; RUN: llvm-as < %s | opt -lowerinvoke -enable-correct-eh-support -disable-output
declare fastcc int %ll_listnext__listiterPtr()
declare fastcc i32 @ll_listnext__listiterPtr()
fastcc int %WorkTask.fn() {
define fastcc i32 @WorkTask.fn() {
block0:
%v2679 = invoke fastcc int %ll_listnext__listiterPtr( )
to label %block9 unwind label %block8_exception_handling ; <int> [#uses=1]
%v2679 = invoke fastcc i32 @ll_listnext__listiterPtr( )
to label %block9 unwind label %block8_exception_handling ; <i32> [#uses=1]
block8_exception_handling: ; preds = %block0
ret int 0
ret i32 0
block9: ; preds = %block0
%i_2689 = phi int [ %v2679, %block0 ] ; <int> [#uses=0]
ret int %i_2689
%i_2689 = phi i32 [ %v2679, %block0 ] ; <i32> [#uses=1]
ret i32 %i_2689
}

View File

@ -1,27 +1,30 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -lowerinvoke -disable-output -enable-correct-eh-support
; RUN: llvm-as < %s | opt -lowerinvoke -disable-output -enable-correct-eh-support
implementation
int %foo() {
invoke int %foo() to label %Ok unwind label %Crap
Ok:
invoke int %foo() to label %Ok2 unwind label %Crap
Ok2:
ret int 2
Crap:
ret int 1
define i32 @foo() {
invoke i32 @foo( )
to label %Ok unwind label %Crap ; <i32>:1 [#uses=0]
Ok: ; preds = %0
invoke i32 @foo( )
to label %Ok2 unwind label %Crap ; <i32>:2 [#uses=0]
Ok2: ; preds = %Ok
ret i32 2
Crap: ; preds = %Ok, %0
ret i32 1
}
int %bar(int %blah) {
define i32 @bar(i32 %blah) {
br label %doit
doit:
;; Value live across an unwind edge.
%B2 = add int %blah, 1
invoke int %foo() to label %Ok unwind label %Crap
Ok:
invoke int %foo() to label %Ok2 unwind label %Crap
Ok2:
ret int 2
Crap:
ret int %B2
doit: ; preds = %0
;; Value live across an unwind edge.
%B2 = add i32 %blah, 1 ; <i32> [#uses=1]
invoke i32 @foo( )
to label %Ok unwind label %Crap ; <i32>:1 [#uses=0]
Ok: ; preds = %doit
invoke i32 @foo( )
to label %Ok2 unwind label %Crap ; <i32>:2 [#uses=0]
Ok2: ; preds = %Ok
ret i32 2
Crap: ; preds = %Ok, %doit
ret i32 %B2
}

View File

@ -1,16 +1,16 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -lowersetjmp -disable-output
%struct.jmpenv = type { int, sbyte }
; RUN: llvm-as < %s | opt -lowersetjmp -disable-output
implementation
%struct.jmpenv = type { i32, i8 }
declare void %Perl_sv_setpv()
declare int %llvm.setjmp(int *)
declare void @Perl_sv_setpv()
void %perl_call_sv() {
call void %Perl_sv_setpv( )
%tmp.335 = getelementptr %struct.jmpenv* null, long 0, uint 0
%tmp.336 = call int %llvm.setjmp( int* null )
store int %tmp.336, int* %tmp.335
declare i32 @llvm.setjmp(i32*)
define void @perl_call_sv() {
call void @Perl_sv_setpv( )
%tmp.335 = getelementptr %struct.jmpenv* null, i64 0, i32 0 ; <i32*> [#uses=1]
%tmp.336 = call i32 @llvm.setjmp( i32* null ) ; <i32> [#uses=1]
store i32 %tmp.336, i32* %tmp.335
ret void
}

View File

@ -1,32 +1,32 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -lowersetjmp | llvm-dis | grep invoke
; RUN: llvm-as < %s | opt -lowersetjmp | llvm-dis | grep invoke
%JmpBuf = type int
%.str_1 = internal constant [13 x sbyte] c"returned %d\0A\00"
%JmpBuf = type i32
@.str_1 = internal constant [13 x i8] c"returned %d\0A\00" ; <[13 x i8]*> [#uses=1]
implementation
declare void @llvm.longjmp(i32*, i32)
declare void %llvm.longjmp(%JmpBuf *%B, int %Val)
declare int %llvm.setjmp(%JmpBuf *%B)
declare i32 @llvm.setjmp(i32*)
declare void %foo()
declare void @foo()
int %simpletest() {
%B = alloca %JmpBuf
%Val = call int %llvm.setjmp(%JmpBuf* %B)
%V = cast int %Val to bool
br bool %V, label %LongJumped, label %Normal
Normal:
call void %foo()
call void %llvm.longjmp(%JmpBuf* %B, int 42)
ret int 0 ;; not reached
LongJumped:
ret int %Val
define i32 @simpletest() {
%B = alloca i32 ; <i32*> [#uses=2]
%Val = call i32 @llvm.setjmp( i32* %B ) ; <i32> [#uses=2]
%V = icmp ne i32 %Val, 0 ; <i1> [#uses=1]
br i1 %V, label %LongJumped, label %Normal
Normal: ; preds = %0
call void @foo( )
call void @llvm.longjmp( i32* %B, i32 42 )
ret i32 0
LongJumped: ; preds = %0
ret i32 %Val
}
declare int %printf(sbyte*, ...)
declare i32 @printf(i8*, ...)
int %main() {
%V = call int %simpletest()
call int(sbyte*, ...)* %printf(sbyte* getelementptr ([13 x sbyte]* %.str_1, long 0, long 0), int %V)
ret int 0
define i32 @main() {
%V = call i32 @simpletest( ) ; <i32> [#uses=1]
call i32 (i8*, ...)* @printf( i8* getelementptr ([13 x i8]* @.str_1, i64 0, i64 0), i32 %V ) ; <i32>:1 [#uses=0]
ret i32 0
}

View File

@ -1,17 +1,15 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -lowerswitch
; RUN: llvm-as < %s | opt -lowerswitch
void %child(int %ct.1) {
entry: ; No predecessors!
switch uint 0, label %return [
uint 3, label %UnifiedExitNode
uint 0, label %return
]
return: ; preds = %entry, %entry
%result.0 = phi int* [ null, %entry ], [ null, %entry ] ; <%struct.quad_struct*> [#uses=0]
br label %UnifiedExitNode
UnifiedExitNode: ; preds = %entry, %return, %entry, %entry
ret void
define void @child(i32 %ct.1) {
entry:
switch i32 0, label %return [
i32 3, label %UnifiedExitNode
i32 0, label %return
]
return: ; preds = %entry, %entry
%result.0 = phi i32* [ null, %entry ], [ null, %entry ] ; <i32*> [#uses=0]
br label %UnifiedExitNode
UnifiedExitNode: ; preds = %return, %entry
ret void
}

View File

@ -1,7 +1,9 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -lowerswitch
; RUN: llvm-as < %s | opt -lowerswitch
void %test() {
switch uint 0, label %Next []
Next:
define void @test() {
switch i32 0, label %Next [
]
Next: ; preds = %0
ret void
}

View File

@ -1,21 +1,19 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -lowerswitch -disable-output
; RUN: llvm-as < %s | opt -lowerswitch -disable-output
void %solve() {
define void @solve() {
entry:
%targetBlock = call ushort %solve_code( ) ; <ushort> [#uses=1]
%targetBlock = call i16 @solve_code( ) ; <i16> [#uses=1]
br label %codeReplTail
then.1: ; preds = %codeReplTail
ret void
loopexit.0: ; preds = %codeReplTail
ret void
codeReplTail: ; preds = %entry, %codeReplTail
switch ushort %targetBlock, label %codeReplTail [
ushort 0, label %loopexit.0
ushort 1, label %then.1
codeReplTail: ; preds = %codeReplTail, %entry
switch i16 %targetBlock, label %codeReplTail [
i16 0, label %loopexit.0
i16 1, label %then.1
]
}
declare ushort %solve_code()
declare i16 @solve_code()

View File

@ -1,17 +1,16 @@
; This testcases makes sure that mem2reg can handle unreachable blocks.
; RUN: llvm-upgrade < %s | llvm-as | opt -mem2reg
; RUN: llvm-as < %s | opt -mem2reg
int %test() {
%X = alloca int
store int 6, int* %X
define i32 @test() {
%X = alloca i32 ; <i32*> [#uses=2]
store i32 6, i32* %X
br label %Loop
Loop:
store int 5, int* %X
Loop: ; preds = %EndOfLoop, %0
store i32 5, i32* %X
br label %EndOfLoop
Unreachable:
Unreachable: ; No predecessors!
br label %EndOfLoop
EndOfLoop:
EndOfLoop: ; preds = %Unreachable, %Loop
br label %Loop
}

View File

@ -1,15 +1,16 @@
; Mem2reg used to only add one incoming value to a PHI node, even if it had
; multiple incoming edges from a block.
;
; RUN: llvm-upgrade < %s | llvm-as | opt -mem2reg -disable-output
; RUN: llvm-as < %s | opt -mem2reg -disable-output
int %test(bool %c1, bool %c2) {
%X = alloca int
br bool %c1, label %Exit, label %B2
B2:
store int 2, int* %X
br bool %c2, label %Exit, label %Exit
Exit:
%Y = load int *%X
ret int %Y
define i32 @test(i1 %c1, i1 %c2) {
%X = alloca i32 ; <i32*> [#uses=2]
br i1 %c1, label %Exit, label %B2
B2: ; preds = %0
store i32 2, i32* %X
br i1 %c2, label %Exit, label %Exit
Exit: ; preds = %B2, %B2, %0
%Y = load i32* %X ; <i32> [#uses=1]
ret i32 %Y
}

View File

@ -1,16 +1,16 @@
; Promoting some values allows promotion of other values.
; RUN: llvm-upgrade < %s | llvm-as | opt -mem2reg | llvm-dis | not grep alloca
; RUN: llvm-as < %s | opt -mem2reg | llvm-dis | not grep alloca
int %test2() {
%result = alloca int ; ty=int*
%a = alloca int ; ty=int*
%p = alloca int* ; ty=int**
store int 0, int* %a
store int* %a, int** %p
%tmp.0 = load int** %p ; ty=int*
%tmp.1 = load int* %tmp.0 ; ty=int
store int %tmp.1, int* %result
%tmp.2 = load int* %result ; ty=int
ret int %tmp.2
define i32 @test2() {
%result = alloca i32 ; <i32*> [#uses=2]
%a = alloca i32 ; <i32*> [#uses=2]
%p = alloca i32* ; <i32**> [#uses=2]
store i32 0, i32* %a
store i32* %a, i32** %p
%tmp.0 = load i32** %p ; <i32*> [#uses=1]
%tmp.1 = load i32* %tmp.0 ; <i32> [#uses=1]
store i32 %tmp.1, i32* %result
%tmp.2 = load i32* %result ; <i32> [#uses=1]
ret i32 %tmp.2
}

View File

@ -1,21 +1,22 @@
; Mem2reg should not insert dead PHI nodes! The naive algorithm inserts a PHI
; node in L3, even though there is no load of %A in anything dominated by L3.
; RUN: llvm-upgrade < %s | llvm-as | opt -mem2reg | llvm-dis | not grep phi
; RUN: llvm-as < %s | opt -mem2reg | llvm-dis | not grep phi
void %test(int %B, bool %C) {
%A = alloca int
store int %B, int* %A
br bool %C, label %L1, label %L2
L1:
store int %B, int* %A
%D = load int* %A
call void %test(int %D, bool false)
define void @test(i32 %B, i1 %C) {
%A = alloca i32 ; <i32*> [#uses=4]
store i32 %B, i32* %A
br i1 %C, label %L1, label %L2
L1: ; preds = %0
store i32 %B, i32* %A
%D = load i32* %A ; <i32> [#uses=1]
call void @test( i32 %D, i1 false )
br label %L3
L2:
%E = load int* %A
call void %test(int %E, bool true)
L2: ; preds = %0
%E = load i32* %A ; <i32> [#uses=1]
call void @test( i32 %E, i1 true )
br label %L3
L3:
L3: ; preds = %L2, %L1
ret void
}

View File

@ -1,51 +1,47 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -mem2reg -instcombine | llvm-dis | grep store
; RUN: llvm-as < %s | opt -mem2reg -instcombine | llvm-dis | grep store
; PR590
void %zero(sbyte* %p, int %n) {
define void @zero(i8* %p, i32 %n) {
entry:
%p_addr = alloca sbyte* ; <sbyte**> [#uses=2]
%n_addr = alloca int ; <int*> [#uses=2]
%i = alloca int ; <int*> [#uses=6]
%out = alloca int ; <int*> [#uses=2]
%undef = alloca int ; <int*> [#uses=2]
store sbyte* %p, sbyte** %p_addr
store int %n, int* %n_addr
store int 0, int* %i
%p_addr = alloca i8* ; <i8**> [#uses=2]
%n_addr = alloca i32 ; <i32*> [#uses=2]
%i = alloca i32 ; <i32*> [#uses=6]
%out = alloca i32 ; <i32*> [#uses=2]
%undef = alloca i32 ; <i32*> [#uses=2]
store i8* %p, i8** %p_addr
store i32 %n, i32* %n_addr
store i32 0, i32* %i
br label %loopentry
loopentry: ; preds = %endif, %entry
%tmp.0 = load int* %n_addr ; <int> [#uses=1]
%tmp.1 = add int %tmp.0, 1 ; <int> [#uses=1]
%tmp.2 = load int* %i ; <int> [#uses=1]
%tmp.3 = setgt int %tmp.1, %tmp.2 ; <bool> [#uses=2]
%tmp.4 = cast bool %tmp.3 to int ; <int> [#uses=0]
br bool %tmp.3, label %no_exit, label %return
%tmp.0 = load i32* %n_addr ; <i32> [#uses=1]
%tmp.1 = add i32 %tmp.0, 1 ; <i32> [#uses=1]
%tmp.2 = load i32* %i ; <i32> [#uses=1]
%tmp.3 = icmp sgt i32 %tmp.1, %tmp.2 ; <i1> [#uses=2]
%tmp.4 = zext i1 %tmp.3 to i32 ; <i32> [#uses=0]
br i1 %tmp.3, label %no_exit, label %return
no_exit: ; preds = %loopentry
%tmp.5 = load int* %undef ; <int> [#uses=1]
store int %tmp.5, int* %out
store int 0, int* %undef
%tmp.6 = load int* %i ; <int> [#uses=1]
%tmp.7 = setgt int %tmp.6, 0 ; <bool> [#uses=2]
%tmp.8 = cast bool %tmp.7 to int ; <int> [#uses=0]
br bool %tmp.7, label %then, label %endif
%tmp.5 = load i32* %undef ; <i32> [#uses=1]
store i32 %tmp.5, i32* %out
store i32 0, i32* %undef
%tmp.6 = load i32* %i ; <i32> [#uses=1]
%tmp.7 = icmp sgt i32 %tmp.6, 0 ; <i1> [#uses=2]
%tmp.8 = zext i1 %tmp.7 to i32 ; <i32> [#uses=0]
br i1 %tmp.7, label %then, label %endif
then: ; preds = %no_exit
%tmp.9 = load sbyte** %p_addr ; <sbyte*> [#uses=1]
%tmp.10 = load int* %i ; <int> [#uses=1]
%tmp.11 = sub int %tmp.10, 1 ; <int> [#uses=1]
%tmp.12 = getelementptr sbyte* %tmp.9, int %tmp.11 ; <sbyte*> [#uses=1]
%tmp.13 = load int* %out ; <int> [#uses=1]
%tmp.14 = cast int %tmp.13 to sbyte ; <sbyte> [#uses=1]
store sbyte %tmp.14, sbyte* %tmp.12
%tmp.9 = load i8** %p_addr ; <i8*> [#uses=1]
%tmp.10 = load i32* %i ; <i32> [#uses=1]
%tmp.11 = sub i32 %tmp.10, 1 ; <i32> [#uses=1]
%tmp.12 = getelementptr i8* %tmp.9, i32 %tmp.11 ; <i8*> [#uses=1]
%tmp.13 = load i32* %out ; <i32> [#uses=1]
%tmp.14 = trunc i32 %tmp.13 to i8 ; <i8> [#uses=1]
store i8 %tmp.14, i8* %tmp.12
br label %endif
endif: ; preds = %then, %no_exit
%tmp.15 = load int* %i ; <int> [#uses=1]
%inc = add int %tmp.15, 1 ; <int> [#uses=1]
store int %inc, int* %i
%tmp.15 = load i32* %i ; <i32> [#uses=1]
%inc = add i32 %tmp.15, 1 ; <i32> [#uses=1]
store i32 %inc, i32* %i
br label %loopentry
return: ; preds = %loopentry
ret void
}

View File

@ -1,88 +1,62 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -mem2reg -disable-output
; RUN: llvm-as < %s | opt -mem2reg -disable-output
; PR670
void %printk(int, ...) {
define void @printk(i32, ...) {
entry:
%flags = alloca uint ; <uint*> [#uses=2]
br bool false, label %then.0, label %endif.0
%flags = alloca i32 ; <i32*> [#uses=2]
br i1 false, label %then.0, label %endif.0
then.0: ; preds = %entry
br label %endif.0
endif.0: ; preds = %then.0, %entry
store uint 0, uint* %flags
store i32 0, i32* %flags
br label %loopentry
loopentry: ; preds = %endif.3, %endif.0
br bool false, label %no_exit, label %loopexit
br i1 false, label %no_exit, label %loopexit
no_exit: ; preds = %loopentry
br bool false, label %then.1, label %endif.1
br i1 false, label %then.1, label %endif.1
then.1: ; preds = %no_exit
br bool false, label %shortcirc_done.0, label %shortcirc_next.0
br i1 false, label %shortcirc_done.0, label %shortcirc_next.0
shortcirc_next.0: ; preds = %then.1
br label %shortcirc_done.0
shortcirc_done.0: ; preds = %shortcirc_next.0, %then.1
br bool false, label %shortcirc_done.1, label %shortcirc_next.1
br i1 false, label %shortcirc_done.1, label %shortcirc_next.1
shortcirc_next.1: ; preds = %shortcirc_done.0
br label %shortcirc_done.1
shortcirc_done.1: ; preds = %shortcirc_next.1, %shortcirc_done.0
br bool false, label %shortcirc_done.2, label %shortcirc_next.2
br i1 false, label %shortcirc_done.2, label %shortcirc_next.2
shortcirc_next.2: ; preds = %shortcirc_done.1
br label %shortcirc_done.2
shortcirc_done.2: ; preds = %shortcirc_next.2, %shortcirc_done.1
br bool false, label %then.2, label %endif.2
br i1 false, label %then.2, label %endif.2
then.2: ; preds = %shortcirc_done.2
br label %endif.2
endif.2: ; preds = %then.2, %shortcirc_done.2
br label %endif.1
endif.1: ; preds = %endif.2, %no_exit
br bool false, label %then.3, label %endif.3
br i1 false, label %then.3, label %endif.3
then.3: ; preds = %endif.1
br label %endif.3
endif.3: ; preds = %then.3, %endif.1
br label %loopentry
loopexit: ; preds = %loopentry
br label %endif.4
then.4: ; No predecessors!
%tmp.61 = load uint* %flags ; <uint> [#uses=0]
%tmp.61 = load i32* %flags ; <i32> [#uses=0]
br label %out
dead_block_after_goto: ; No predecessors!
br label %endif.4
endif.4: ; preds = %dead_block_after_goto, %loopexit
br bool false, label %then.5, label %else
br i1 false, label %then.5, label %else
then.5: ; preds = %endif.4
br label %endif.5
else: ; preds = %endif.4
br label %endif.5
endif.5: ; preds = %else, %then.5
br label %out
out: ; preds = %endif.5, %then.4
br label %return
after_ret: ; No predecessors!
br label %return
return: ; preds = %after_ret, %out
ret void
}

View File

@ -1,24 +1,18 @@
; Simple sanity check testcase. Both alloca's should be eliminated.
; RUN: llvm-upgrade < %s | llvm-as | opt -mem2reg | llvm-dis | not grep alloca
; RUN: llvm-as < %s | opt -mem2reg | llvm-dis | not grep alloca
implementation
double "testfunc"(int %i, double %j)
begin
%I = alloca int
%J = alloca double
store int %i, int* %I
define double @testfunc(i32 %i, double %j) {
%I = alloca i32 ; <i32*> [#uses=4]
%J = alloca double ; <double*> [#uses=2]
store i32 %i, i32* %I
store double %j, double* %J
%t1 = load int* %I
%t2 = add int %t1, 1
store int %t2, int* %I
%t3 = load int* %I
%t4 = cast int %t3 to double
%t5 = load double* %J
%t6 = mul double %t4, %t5
%t1 = load i32* %I ; <i32> [#uses=1]
%t2 = add i32 %t1, 1 ; <i32> [#uses=1]
store i32 %t2, i32* %I
%t3 = load i32* %I ; <i32> [#uses=1]
%t4 = sitofp i32 %t3 to double ; <double> [#uses=1]
%t5 = load double* %J ; <double> [#uses=1]
%t6 = mul double %t4, %t5 ; <double> [#uses=1]
ret double %t6
end
}

View File

@ -1,14 +1,13 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -mem2reg | llvm-dis | not grep phi
; RUN: llvm-as < %s | opt -mem2reg | llvm-dis | not grep phi
implementation
int %testfunc(bool %C, int %i, sbyte %j) {
%I = alloca int
br bool %C, label %T, label %Cont
T:
store int %i, int* %I
define i32 @testfunc(i1 %C, i32 %i, i8 %j) {
%I = alloca i32 ; <i32*> [#uses=2]
br i1 %C, label %T, label %Cont
T: ; preds = %0
store i32 %i, i32* %I
br label %Cont
Cont:
%Y = load int* %I ;; %Y = phi %i, undef -> %Y = %i
ret int %Y
Cont: ; preds = %T, %0
%Y = load i32* %I ; <i32> [#uses=1]
ret i32 %Y
}