aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/Mem2Reg
diff options
context:
space:
mode:
authorTanya Lattner <tonic@nondot.org>2008-03-19 07:28:33 +0000
committerTanya Lattner <tonic@nondot.org>2008-03-19 07:28:33 +0000
commite6d5d39c072d3b16ff4183c515d7ccf198192958 (patch)
tree57312300a30d0b10726d10d7928aa6f657e9ad28 /test/Transforms/Mem2Reg
parentce7d5db4d86b6eef20ffb9e981a1f0d428879e57 (diff)
downloadexternal_llvm-e6d5d39c072d3b16ff4183c515d7ccf198192958.zip
external_llvm-e6d5d39c072d3b16ff4183c515d7ccf198192958.tar.gz
external_llvm-e6d5d39c072d3b16ff4183c515d7ccf198192958.tar.bz2
Upgrade tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48538 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/Mem2Reg')
-rw-r--r--test/Transforms/Mem2Reg/2003-04-18-DeadBlockProblem.ll19
-rw-r--r--test/Transforms/Mem2Reg/2003-04-24-MultipleIdenticalSuccessors.ll21
-rw-r--r--test/Transforms/Mem2Reg/2003-06-26-IterativePromote.ll24
-rw-r--r--test/Transforms/Mem2Reg/2003-10-05-DeadPHIInsertion.ll27
-rw-r--r--test/Transforms/Mem2Reg/2005-06-30-ReadBeforeWrite.ll72
-rw-r--r--test/Transforms/Mem2Reg/2005-11-28-Crash.ll54
-rw-r--r--test/Transforms/Mem2Reg/PromoteMemToRegister.ll34
-rw-r--r--test/Transforms/Mem2Reg/UndefValuesMerge.ll21
8 files changed, 118 insertions, 154 deletions
diff --git a/test/Transforms/Mem2Reg/2003-04-18-DeadBlockProblem.ll b/test/Transforms/Mem2Reg/2003-04-18-DeadBlockProblem.ll
index d6f1b77..78bfcb4 100644
--- a/test/Transforms/Mem2Reg/2003-04-18-DeadBlockProblem.ll
+++ b/test/Transforms/Mem2Reg/2003-04-18-DeadBlockProblem.ll
@@ -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
}
+
diff --git a/test/Transforms/Mem2Reg/2003-04-24-MultipleIdenticalSuccessors.ll b/test/Transforms/Mem2Reg/2003-04-24-MultipleIdenticalSuccessors.ll
index 7cd38c2..04e8db3 100644
--- a/test/Transforms/Mem2Reg/2003-04-24-MultipleIdenticalSuccessors.ll
+++ b/test/Transforms/Mem2Reg/2003-04-24-MultipleIdenticalSuccessors.ll
@@ -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
}
+
diff --git a/test/Transforms/Mem2Reg/2003-06-26-IterativePromote.ll b/test/Transforms/Mem2Reg/2003-06-26-IterativePromote.ll
index ce274fa..27d0015 100644
--- a/test/Transforms/Mem2Reg/2003-06-26-IterativePromote.ll
+++ b/test/Transforms/Mem2Reg/2003-06-26-IterativePromote.ll
@@ -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
}
diff --git a/test/Transforms/Mem2Reg/2003-10-05-DeadPHIInsertion.ll b/test/Transforms/Mem2Reg/2003-10-05-DeadPHIInsertion.ll
index ab4b661..5a27b20 100644
--- a/test/Transforms/Mem2Reg/2003-10-05-DeadPHIInsertion.ll
+++ b/test/Transforms/Mem2Reg/2003-10-05-DeadPHIInsertion.ll
@@ -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
}
+
diff --git a/test/Transforms/Mem2Reg/2005-06-30-ReadBeforeWrite.ll b/test/Transforms/Mem2Reg/2005-06-30-ReadBeforeWrite.ll
index c64d848..b053aa1 100644
--- a/test/Transforms/Mem2Reg/2005-06-30-ReadBeforeWrite.ll
+++ b/test/Transforms/Mem2Reg/2005-06-30-ReadBeforeWrite.ll
@@ -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
}
diff --git a/test/Transforms/Mem2Reg/2005-11-28-Crash.ll b/test/Transforms/Mem2Reg/2005-11-28-Crash.ll
index 01e8b85..a985db3 100644
--- a/test/Transforms/Mem2Reg/2005-11-28-Crash.ll
+++ b/test/Transforms/Mem2Reg/2005-11-28-Crash.ll
@@ -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
}
diff --git a/test/Transforms/Mem2Reg/PromoteMemToRegister.ll b/test/Transforms/Mem2Reg/PromoteMemToRegister.ll
index 8bf7b51..fdc33fb 100644
--- a/test/Transforms/Mem2Reg/PromoteMemToRegister.ll
+++ b/test/Transforms/Mem2Reg/PromoteMemToRegister.ll
@@ -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
+}
+
diff --git a/test/Transforms/Mem2Reg/UndefValuesMerge.ll b/test/Transforms/Mem2Reg/UndefValuesMerge.ll
index dc2f011..0d20d7d 100644
--- a/test/Transforms/Mem2Reg/UndefValuesMerge.ll
+++ b/test/Transforms/Mem2Reg/UndefValuesMerge.ll
@@ -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
}
+