Upgrade tests to not use llvm-upgrade.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48484 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Tanya Lattner 2008-03-18 04:14:37 +00:00
parent f04d8d1593
commit 683283763f
23 changed files with 334 additions and 375 deletions

View File

@ -1,12 +1,13 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | \
; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | \
; RUN: grep alloca | grep {4 x}
; Test that an array is not incorrectly deconstructed...
int %test() {
%X = alloca [4 x int]
%Y = getelementptr [4 x int]* %X, long 0, long 0
%Z = getelementptr int* %Y, long 1 ; Must preserve arrayness!
%A = load int* %Z
ret int %A
define i32 @test() {
%X = alloca [4 x i32] ; <[4 x i32]*> [#uses=1]
%Y = getelementptr [4 x i32]* %X, i64 0, i64 0 ; <i32*> [#uses=1]
; Must preserve arrayness!
%Z = getelementptr i32* %Y, i64 1 ; <i32*> [#uses=1]
%A = load i32* %Z ; <i32> [#uses=1]
ret i32 %A
}

View File

@ -1,7 +1,8 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl
; RUN: llvm-as < %s | opt -scalarrepl
void %main() {
%E = alloca { { int, float, double, long }, { int, float, double, long } } ; <{ { int, float, double, long }, { int, float, double, long } }*> [#uses=1]
%tmp.151 = getelementptr { { int, float, double, long }, { int, float, double, long } }* %E, long 0, uint 1, uint 3 ; <long*> [#uses=0]
define void @main() {
%E = alloca { { i32, float, double, i64 }, { i32, float, double, i64 } } ; <{ { i32, float, double, i64 }, { i32, float, double, i64 } }*> [#uses=1]
%tmp.151 = getelementptr { { i32, float, double, i64 }, { i32, float, double, i64 } }* %E, i64 0, i32 1, i32 3 ; <i64*> [#uses=0]
ret void
}

View File

@ -1,9 +1,10 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl
; RUN: llvm-as < %s | opt -scalarrepl
int %test() {
%X = alloca { [ 4 x int] }
%Y = getelementptr { [ 4 x int] }* %X, long 0, uint 0, long 2
store int 4, int* %Y
%Z = load int* %Y
ret int %Z
define i32 @test() {
%X = alloca { [4 x i32] } ; <{ [4 x i32] }*> [#uses=1]
%Y = getelementptr { [4 x i32] }* %X, i64 0, i32 0, i64 2 ; <i32*> [#uses=2]
store i32 4, i32* %Y
%Z = load i32* %Y ; <i32> [#uses=1]
ret i32 %Z
}

View File

@ -1,12 +1,13 @@
; Scalar replacement was incorrectly promoting this alloca!!
;
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | \
; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | \
; RUN: sed {s/;.*//g} | grep \[
sbyte *%test() {
%A = alloca [30 x sbyte]
%B = getelementptr [30 x sbyte]* %A, long 0, long 0
%C = getelementptr sbyte* %B, long 1
store sbyte 0, sbyte* %B
ret sbyte* %C
define i8* @test() {
%A = alloca [30 x i8] ; <[30 x i8]*> [#uses=1]
%B = getelementptr [30 x i8]* %A, i64 0, i64 0 ; <i8*> [#uses=2]
%C = getelementptr i8* %B, i64 1 ; <i8*> [#uses=1]
store i8 0, i8* %B
ret i8* %C
}

View File

@ -1,15 +1,16 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | \
; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | \
; RUN: grep alloca | grep \{
implementation ; Functions:
declare int %.callback_1(sbyte*)
declare void %.iter_2(int (sbyte*)*, sbyte*)
declare i32 @.callback_1(i8*)
int %main() {
%d = alloca { [80 x sbyte], int, uint }
%tmp.0 = getelementptr { [80 x sbyte], int, uint }* %d, long 0, uint 2
store uint 0, uint* %tmp.0
%tmp.1 = getelementptr { [80 x sbyte], int, uint }* %d, long 0, uint 0, long 0
call void %.iter_2( int (sbyte*)* %.callback_1, sbyte* %tmp.1 )
ret int 0
declare void @.iter_2(i32 (i8*)*, i8*)
define i32 @main() {
%d = alloca { [80 x i8], i32, i32 } ; <{ [80 x i8], i32, i32 }*> [#uses=2]
%tmp.0 = getelementptr { [80 x i8], i32, i32 }* %d, i64 0, i32 2 ; <i32*> [#uses=1]
store i32 0, i32* %tmp.0
%tmp.1 = getelementptr { [80 x i8], i32, i32 }* %d, i64 0, i32 0, i64 0 ; <i8*> [#uses=1]
call void @.iter_2( i32 (i8*)* @.callback_1, i8* %tmp.1 )
ret i32 0
}

View File

@ -1,34 +1,28 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl -disable-output
target endian = big
target pointersize = 32
%struct.rtx_def = type { [2 x ubyte], int, [1 x %union.rtunion_def] }
%union.rtunion_def = type { uint }
; RUN: llvm-as < %s | opt -scalarrepl -disable-output
implementation ; Functions:
target datalayout = "E-p:32:32"
%struct.rtx_def = type { [2 x i8], i32, [1 x %union.rtunion_def] }
%union.rtunion_def = type { i32 }
void %find_reloads() {
define void @find_reloads() {
entry:
%c_addr.i = alloca sbyte ; <sbyte*> [#uses=1]
switch uint 0, label %return [
uint 36, label %label.7
uint 34, label %label.7
uint 41, label %label.5
%c_addr.i = alloca i8 ; <i8*> [#uses=1]
switch i32 0, label %return [
i32 36, label %label.7
i32 34, label %label.7
i32 41, label %label.5
]
label.5: ; preds = %entry
ret void
label.7: ; preds = %entry, %entry
br bool false, label %then.4, label %switchexit.0
br i1 false, label %then.4, label %switchexit.0
then.4: ; preds = %label.7
%tmp.0.i = cast sbyte* %c_addr.i to int* ; <int*> [#uses=1]
store int 44, int* %tmp.0.i
%tmp.0.i = bitcast i8* %c_addr.i to i32* ; <i32*> [#uses=1]
store i32 44, i32* %tmp.0.i
ret void
switchexit.0: ; preds = %label.7
ret void
return: ; preds = %entry
ret void
}

View File

@ -1,12 +1,12 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl -disable-output
; RUN: llvm-as < %s | opt -scalarrepl -disable-output
target endian = big
target pointersize = 32
target datalayout = "E-p:32:32"
int %test(long %L) {
%X = alloca int
%Y = cast int* %X to ulong*
store ulong 0, ulong* %Y
%Z = load int *%X
ret int %Z
define i32 @test(i64 %L) {
%X = alloca i32 ; <i32*> [#uses=2]
%Y = bitcast i32* %X to i64* ; <i64*> [#uses=1]
store i64 0, i64* %Y
%Z = load i32* %X ; <i32> [#uses=1]
ret i32 %Z
}

View File

@ -1,18 +1,18 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl -disable-output
; RUN: llvm-as < %s | opt -scalarrepl -disable-output
void %output_toc() {
define void @output_toc() {
entry:
%buf = alloca [256 x sbyte], align 16 ; <[256 x sbyte]*> [#uses=1]
%name = alloca sbyte*, align 4 ; <sbyte**> [#uses=1]
%real_name = alloca sbyte*, align 4 ; <sbyte**> [#uses=0]
"alloca point" = cast int 0 to int ; <int> [#uses=0]
%buf = cast [256 x sbyte]* %buf to sbyte* ; <sbyte*> [#uses=1]
store sbyte* %buf, sbyte** %name
call void %abort( )
%buf = alloca [256 x i8], align 16 ; <[256 x i8]*> [#uses=1]
%name = alloca i8*, align 4 ; <i8**> [#uses=1]
%real_name = alloca i8*, align 4 ; <i8**> [#uses=0]
%"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
%buf.upgrd.1 = bitcast [256 x i8]* %buf to i8* ; <i8*> [#uses=1]
store i8* %buf.upgrd.1, i8** %name
call void @abort( )
unreachable
return: ; No predecessors!
ret void
}
declare void %abort()
declare void @abort()

View File

@ -1,75 +1,57 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl -disable-output
; RUN: llvm-as < %s | opt -scalarrepl -disable-output
; END.
target datalayout = "e-p:32:32"
target endian = little
target pointersize = 32
target triple = "i686-apple-darwin8.7.2"
implementation ; Functions:
void %glgProcessColor() {
define void @glgProcessColor() {
entry:
%source_ptr = alloca sbyte*, align 4 ; <sbyte**> [#uses=2]
br bool false, label %bb1357, label %cond_next583
%source_ptr = alloca i8*, align 4 ; <i8**> [#uses=2]
br i1 false, label %bb1357, label %cond_next583
cond_next583: ; preds = %entry
ret void
bb1357: ; preds = %entry
br bool false, label %bb1365, label %bb27055
br i1 false, label %bb1365, label %bb27055
bb1365: ; preds = %bb1357
switch uint 0, label %cond_next10377 [
uint 0, label %bb4679
uint 1, label %bb4679
uint 2, label %bb4679
uint 3, label %bb4679
uint 4, label %bb5115
uint 5, label %bb6651
uint 6, label %bb7147
uint 7, label %bb8683
uint 8, label %bb9131
uint 9, label %bb9875
uint 10, label %bb4679
uint 11, label %bb4859
uint 12, label %bb4679
uint 16, label %bb10249
switch i32 0, label %cond_next10377 [
i32 0, label %bb4679
i32 1, label %bb4679
i32 2, label %bb4679
i32 3, label %bb4679
i32 4, label %bb5115
i32 5, label %bb6651
i32 6, label %bb7147
i32 7, label %bb8683
i32 8, label %bb9131
i32 9, label %bb9875
i32 10, label %bb4679
i32 11, label %bb4859
i32 12, label %bb4679
i32 16, label %bb10249
]
bb4679: ; preds = %bb1365, %bb1365, %bb1365, %bb1365, %bb1365, %bb1365
ret void
bb4859: ; preds = %bb1365
ret void
bb5115: ; preds = %bb1365
ret void
bb6651: ; preds = %bb1365
ret void
bb7147: ; preds = %bb1365
ret void
bb8683: ; preds = %bb1365
ret void
bb9131: ; preds = %bb1365
ret void
bb9875: ; preds = %bb1365
%source_ptr9884 = cast sbyte** %source_ptr to ubyte** ; <ubyte**> [#uses=1]
%tmp9885 = load ubyte** %source_ptr9884 ; <ubyte*> [#uses=0]
%source_ptr9884 = bitcast i8** %source_ptr to i8** ; <i8**> [#uses=1]
%tmp9885 = load i8** %source_ptr9884 ; <i8*> [#uses=0]
ret void
bb10249: ; preds = %bb1365
%source_ptr10257 = cast sbyte** %source_ptr to ushort** ; <ushort**> [#uses=1]
%tmp10258 = load ushort** %source_ptr10257 ; <ushort*> [#uses=0]
%source_ptr10257 = bitcast i8** %source_ptr to i16** ; <i16**> [#uses=1]
%tmp10258 = load i16** %source_ptr10257 ; <i16*> [#uses=0]
ret void
cond_next10377: ; preds = %bb1365
ret void
bb27055: ; preds = %bb1357
ret void
}

View File

@ -1,19 +1,20 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | \
; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | \
; RUN: grep -F {alloca \[2 x <4 x i32>\]}
int %func(<4 x float> %v0, <4 x float> %v1) {
%vsiidx = alloca [2 x <4 x int>], align 16 ; <[2 x <4 x int>]*> [#uses=3]
%tmp = call <4 x int> %llvm.x86.sse2.cvttps2dq( <4 x float> %v0 ) ; <<4 x int>> [#uses=2]
%tmp = cast <4 x int> %tmp to <2 x long> ; <<2 x long>> [#uses=0]
%tmp = getelementptr [2 x <4 x int>]* %vsiidx, int 0, int 0 ; <<4 x int>*> [#uses=1]
store <4 x int> %tmp, <4 x int>* %tmp
%tmp10 = call <4 x int> %llvm.x86.sse2.cvttps2dq( <4 x float> %v1 ) ; <<4 x int>> [#uses=2]
%tmp10 = cast <4 x int> %tmp10 to <2 x long> ; <<2 x long>> [#uses=0]
%tmp14 = getelementptr [2 x <4 x int>]* %vsiidx, int 0, int 1 ; <<4 x int>*> [#uses=1]
store <4 x int> %tmp10, <4 x int>* %tmp14
%tmp15 = getelementptr [2 x <4 x int>]* %vsiidx, int 0, int 0, int 4 ; <int*> [#uses=1]
%tmp = load int* %tmp15 ; <int> [#uses=1]
ret int %tmp
define i32 @func(<4 x float> %v0, <4 x float> %v1) {
%vsiidx = alloca [2 x <4 x i32>], align 16 ; <[2 x <4 x i32>]*> [#uses=3]
%tmp = call <4 x i32> @llvm.x86.sse2.cvttps2dq( <4 x float> %v0 ) ; <<4 x i32>> [#uses=2]
%tmp.upgrd.1 = bitcast <4 x i32> %tmp to <2 x i64> ; <<2 x i64>> [#uses=0]
%tmp.upgrd.2 = getelementptr [2 x <4 x i32>]* %vsiidx, i32 0, i32 0 ; <<4 x i32>*> [#uses=1]
store <4 x i32> %tmp, <4 x i32>* %tmp.upgrd.2
%tmp10 = call <4 x i32> @llvm.x86.sse2.cvttps2dq( <4 x float> %v1 ) ; <<4 x i32>> [#uses=2]
%tmp10.upgrd.3 = bitcast <4 x i32> %tmp10 to <2 x i64> ; <<2 x i64>> [#uses=0]
%tmp14 = getelementptr [2 x <4 x i32>]* %vsiidx, i32 0, i32 1 ; <<4 x i32>*> [#uses=1]
store <4 x i32> %tmp10, <4 x i32>* %tmp14
%tmp15 = getelementptr [2 x <4 x i32>]* %vsiidx, i32 0, i32 0, i32 4 ; <i32*> [#uses=1]
%tmp.upgrd.4 = load i32* %tmp15 ; <i32> [#uses=1]
ret i32 %tmp.upgrd.4
}
declare <4 x int> %llvm.x86.sse2.cvttps2dq(<4 x float>)
declare <4 x i32> @llvm.x86.sse2.cvttps2dq(<4 x float>)

View File

@ -1,24 +1,20 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl -disable-output
; RUN: llvm-as < %s | opt -scalarrepl -disable-output
; PR1045
target datalayout = "e-p:32:32"
target endian = little
target pointersize = 32
target triple = "i686-pc-linux-gnu"
"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>" = type { "struct.__gnu_cxx::bitmap_allocator<char>::_Alloc_block"* }
"struct.__gnu_cxx::bitmap_allocator<char>" = type { ubyte }
"struct.__gnu_cxx::bitmap_allocator<char>::_Alloc_block" = type { [8 x sbyte] }
%"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>" = type { %"struct.__gnu_cxx::bitmap_allocator<char>::_Alloc_block"* }
%"struct.__gnu_cxx::bitmap_allocator<char>" = type { i8 }
%"struct.__gnu_cxx::bitmap_allocator<char>::_Alloc_block" = type { [8 x i8] }
implementation ; Functions:
void %_ZN9__gnu_cxx16bitmap_allocatorIwE27_M_deallocate_single_objectEPw() {
define void @_ZN9__gnu_cxx16bitmap_allocatorIwE27_M_deallocate_single_objectEPw() {
entry:
%this_addr.i = alloca "struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"* ; <"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"**> [#uses=3]
%tmp = alloca "struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>", align 4 ; <"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"*> [#uses=1]
store "struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"* %tmp, "struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"** %this_addr.i
%tmp.i = load "struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"** %this_addr.i ; <"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"*> [#uses=1]
%tmp.i = bitcast "struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"* %tmp.i to "struct.__gnu_cxx::bitmap_allocator<char>"* ; <"struct.__gnu_cxx::bitmap_allocator<char>"*> [#uses=0]
%tmp1.i = load "struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"** %this_addr.i ; <"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"*> [#uses=1]
%tmp.i = getelementptr "struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"* %tmp1.i, int 0, uint 0 ; <"struct.__gnu_cxx::bitmap_allocator<char>::_Alloc_block"**> [#uses=0]
%this_addr.i = alloca %"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"* ; <%"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"**> [#uses=3]
%tmp = alloca %"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>", align 4 ; <%"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"*> [#uses=1]
store %"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"* %tmp, %"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"** %this_addr.i
%tmp.i = load %"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"** %this_addr.i ; <%"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"*> [#uses=1]
%tmp.i.upgrd.1 = bitcast %"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"* %tmp.i to %"struct.__gnu_cxx::bitmap_allocator<char>"* ; <%"struct.__gnu_cxx::bitmap_allocator<char>"*> [#uses=0]
%tmp1.i = load %"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"** %this_addr.i ; <%"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"*> [#uses=1]
%tmp.i.upgrd.2 = getelementptr %"struct.__gnu_cxx::balloc::_Inclusive_between<__gnu_cxx::bitmap_allocator<char>::_Alloc_block*>"* %tmp1.i, i32 0, i32 0 ; <%"struct.__gnu_cxx::bitmap_allocator<char>::_Alloc_block"**> [#uses=0]
unreachable
}

View File

@ -1,54 +1,51 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | \
; RUN: not grep alloca
; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | \
; RUN: not grep alloca
target endian = big
target pointersize = 32
target datalayout = "E-p:32:32"
target triple = "powerpc-apple-darwin8.0.0"
long %test1(long %X) {
%A = alloca long
store long %X, long* %A
%B = cast long* %A to int*
%C = cast int* %B to sbyte*
store sbyte 0, sbyte* %C
%Y = load long *%A
ret long %Y
define i64 @test1(i64 %X) {
%A = alloca i64 ; <i64*> [#uses=3]
store i64 %X, i64* %A
%B = bitcast i64* %A to i32* ; <i32*> [#uses=1]
%C = bitcast i32* %B to i8* ; <i8*> [#uses=1]
store i8 0, i8* %C
%Y = load i64* %A ; <i64> [#uses=1]
ret i64 %Y
}
sbyte %test2(long %X) {
%X_addr = alloca long ; <long*> [#uses=2]
store long %X, long* %X_addr
%tmp.0 = cast long* %X_addr to int* ; <int*> [#uses=1]
%tmp.1 = getelementptr int* %tmp.0, int 1 ; <int*> [#uses=1]
%tmp.2 = cast int* %tmp.1 to sbyte*
%tmp.3 = getelementptr sbyte* %tmp.2, int 3
%tmp.2 = load sbyte* %tmp.3 ; <int> [#uses=1]
ret sbyte %tmp.2
define i8 @test2(i64 %X) {
%X_addr = alloca i64 ; <i64*> [#uses=2]
store i64 %X, i64* %X_addr
%tmp.0 = bitcast i64* %X_addr to i32* ; <i32*> [#uses=1]
%tmp.1 = getelementptr i32* %tmp.0, i32 1 ; <i32*> [#uses=1]
%tmp.2 = bitcast i32* %tmp.1 to i8* ; <i8*> [#uses=1]
%tmp.3 = getelementptr i8* %tmp.2, i32 3 ; <i8*> [#uses=1]
%tmp.2.upgrd.1 = load i8* %tmp.3 ; <i8> [#uses=1]
ret i8 %tmp.2.upgrd.1
}
short %crafty(long %X) {
%a = alloca { long }
%tmp.0 = getelementptr { long }* %a, int 0, uint 0 ; <long*> [#uses=1]
store long %X, long* %tmp.0
%tmp.3 = cast { long }* %a to [4 x short]* ; <[4 x short]*> [#uses=2]
%tmp.4 = getelementptr [4 x short]* %tmp.3, int 0, int 3 ; <short*> [#uses=1]
%tmp.5 = load short* %tmp.4 ; <short> [#uses=1]
%tmp.8 = getelementptr [4 x short]* %tmp.3, int 0, int 2 ; <short*> [#uses=1]
%tmp.9 = load short* %tmp.8 ; <short> [#uses=1]
%tmp.10 = or short %tmp.9, %tmp.5 ; <short> [#uses=1]
ret short %tmp.10
define i16 @crafty(i64 %X) {
%a = alloca { i64 } ; <{ i64 }*> [#uses=2]
%tmp.0 = getelementptr { i64 }* %a, i32 0, i32 0 ; <i64*> [#uses=1]
store i64 %X, i64* %tmp.0
%tmp.3 = bitcast { i64 }* %a to [4 x i16]* ; <[4 x i16]*> [#uses=2]
%tmp.4 = getelementptr [4 x i16]* %tmp.3, i32 0, i32 3 ; <i16*> [#uses=1]
%tmp.5 = load i16* %tmp.4 ; <i16> [#uses=1]
%tmp.8 = getelementptr [4 x i16]* %tmp.3, i32 0, i32 2 ; <i16*> [#uses=1]
%tmp.9 = load i16* %tmp.8 ; <i16> [#uses=1]
%tmp.10 = or i16 %tmp.9, %tmp.5 ; <i16> [#uses=1]
ret i16 %tmp.10
}
short %crafty2(long %X) {
%a = alloca long
store long %X, long* %a
%tmp.3 = cast long* %a to [4 x short]* ; <[4 x short]*> [#uses=2]
%tmp.4 = getelementptr [4 x short]* %tmp.3, int 0, int 3 ; <short*> [#uses=1]
%tmp.5 = load short* %tmp.4 ; <short> [#uses=1]
%tmp.8 = getelementptr [4 x short]* %tmp.3, int 0, int 2 ; <short*> [#uses=1]
%tmp.9 = load short* %tmp.8 ; <short> [#uses=1]
%tmp.10 = or short %tmp.9, %tmp.5 ; <short> [#uses=1]
ret short %tmp.10
define i16 @crafty2(i64 %X) {
%a = alloca i64 ; <i64*> [#uses=2]
store i64 %X, i64* %a
%tmp.3 = bitcast i64* %a to [4 x i16]* ; <[4 x i16]*> [#uses=2]
%tmp.4 = getelementptr [4 x i16]* %tmp.3, i32 0, i32 3 ; <i16*> [#uses=1]
%tmp.5 = load i16* %tmp.4 ; <i16> [#uses=1]
%tmp.8 = getelementptr [4 x i16]* %tmp.3, i32 0, i32 2 ; <i16*> [#uses=1]
%tmp.9 = load i16* %tmp.8 ; <i16> [#uses=1]
%tmp.10 = or i16 %tmp.9, %tmp.5 ; <i16> [#uses=1]
ret i16 %tmp.10
}

View File

@ -1,19 +1,15 @@
; This is a feature test. Hopefully one day this will be implemented. The
; generated code should perform the appropriate masking operations required
; depending on the endianness of the target...
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | \
; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | \
; RUN: not grep alloca
implementation
int %testfunc(int %i, sbyte %j) {
%I = alloca int
store int %i, int* %I
%P = cast int* %I to sbyte*
store sbyte %j, sbyte* %P
%t = load int* %I
ret int %t
define i32 @testfunc(i32 %i, i8 %j) {
%I = alloca i32 ; <i32*> [#uses=3]
store i32 %i, i32* %I
%P = bitcast i32* %I to i8* ; <i8*> [#uses=1]
store i8 %j, i8* %P
%t = load i32* %I ; <i32> [#uses=1]
ret i32 %t
}

View File

@ -1,10 +1,10 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl -mem2reg | llvm-dis | not grep alloca
; RUN: llvm-as < %s | opt -scalarrepl -mem2reg | llvm-dis | not grep alloca
int %test() {
%X = alloca [ 4 x int ]
%Y = getelementptr [4x int]* %X, long 0, long 0
store int 0, int* %Y
%Z = load int* %Y
ret int %Z
define i32 @test() {
%X = alloca [4 x i32] ; <[4 x i32]*> [#uses=1]
%Y = getelementptr [4 x i32]* %X, i64 0, i64 0 ; <i32*> [#uses=2]
store i32 0, i32* %Y
%Z = load i32* %Y ; <i32> [#uses=1]
ret i32 %Z
}

View File

@ -1,10 +1,11 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl -mem2reg | llvm-dis | grep alloca
; RUN: llvm-as < %s | opt -scalarrepl -mem2reg | llvm-dis | grep alloca
int %test() {
%X = alloca [ 4 x int ]
%Y = getelementptr [4x int]* %X, long 0, long 6 ; Off end of array!
store int 0, int* %Y
%Z = load int* %Y
ret int %Z
define i32 @test() {
%X = alloca [4 x i32] ; <[4 x i32]*> [#uses=1]
; Off end of array!
%Y = getelementptr [4 x i32]* %X, i64 0, i64 6 ; <i32*> [#uses=2]
store i32 0, i32* %Y
%Z = load i32* %Y ; <i32> [#uses=1]
ret i32 %Z
}

View File

@ -1,10 +1,10 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl -mem2reg | llvm-dis | not grep alloca
; RUN: llvm-as < %s | opt -scalarrepl -mem2reg | llvm-dis | not grep alloca
int %test() {
%X = alloca { int, float }
%Y = getelementptr {int,float}* %X, long 0, uint 0
store int 0, int* %Y
%Z = load int* %Y
ret int %Z
define i32 @test() {
%X = alloca { i32, float } ; <{ i32, float }*> [#uses=1]
%Y = getelementptr { i32, float }* %X, i64 0, i32 0 ; <i32*> [#uses=2]
store i32 0, i32* %Y
%Z = load i32* %Y ; <i32> [#uses=1]
ret i32 %Z
}

View File

@ -1,8 +1,8 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg -instcombine -mem2reg | llvm-dis | not grep alloca
; RUN: llvm-as < %s | opt -simplifycfg -instcombine -mem2reg | llvm-dis | not grep alloca
;
; This tests to see if mem2reg can promote alloca instructions whose addresses
; are used by PHI nodes that are immediately loaded. The LLVM C++ front-end
; often generates code that looks like this (when it codegen's ?: exprs as
; often generates code that looks like this (when it codegen's ?: exprs as
; lvalues), so handling this simple extension is quite useful.
;
; This testcase is what the following program looks like when it reaches
@ -15,23 +15,20 @@
; This test checks to make sure the combination of instcombine and mem2reg
; perform the transformation.
int %main() {
define i32 @main() {
entry:
%mem_tmp.0 = alloca int
%mem_tmp.1 = alloca int
store int 0, int* %mem_tmp.0
store int 1, int* %mem_tmp.1
%tmp.1.i = load int* %mem_tmp.1
%tmp.3.i = load int* %mem_tmp.0
%tmp.4.i = setle int %tmp.1.i, %tmp.3.i
br bool %tmp.4.i, label %cond_true.i, label %cond_continue.i
cond_true.i:
br label %cond_continue.i
cond_continue.i:
%mem_tmp.i.0 = phi int* [ %mem_tmp.1, %cond_true.i ], [ %mem_tmp.0, %entry ]
%tmp.3 = load int* %mem_tmp.i.0
ret int %tmp.3
%mem_tmp.0 = alloca i32 ; <i32*> [#uses=3]
%mem_tmp.1 = alloca i32 ; <i32*> [#uses=3]
store i32 0, i32* %mem_tmp.0
store i32 1, i32* %mem_tmp.1
%tmp.1.i = load i32* %mem_tmp.1 ; <i32> [#uses=1]
%tmp.3.i = load i32* %mem_tmp.0 ; <i32> [#uses=1]
%tmp.4.i = icmp sle i32 %tmp.1.i, %tmp.3.i ; <i1> [#uses=1]
br i1 %tmp.4.i, label %cond_true.i, label %cond_continue.i
cond_true.i: ; preds = %entry
br label %cond_continue.i
cond_continue.i: ; preds = %cond_true.i, %entry
%mem_tmp.i.0 = phi i32* [ %mem_tmp.1, %cond_true.i ], [ %mem_tmp.0, %entry ] ; <i32*> [#uses=1]
%tmp.3 = load i32* %mem_tmp.i.0 ; <i32> [#uses=1]
ret i32 %tmp.3
}

View File

@ -1,18 +1,18 @@
; Test promotion of loads that use the result of a select instruction. This
; should be simplified by the instcombine pass.
; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine -mem2reg | llvm-dis | not grep alloca
; RUN: llvm-as < %s | opt -instcombine -mem2reg | llvm-dis | not grep alloca
int %main() {
%mem_tmp.0 = alloca int ; <int*> [#uses=3]
%mem_tmp.1 = alloca int ; <int*> [#uses=3]
store int 0, int* %mem_tmp.0
store int 1, int* %mem_tmp.1
%tmp.1.i = load int* %mem_tmp.1 ; <int> [#uses=1]
%tmp.3.i = load int* %mem_tmp.0 ; <int> [#uses=1]
%tmp.4.i = setle int %tmp.1.i, %tmp.3.i ; <bool> [#uses=1]
%mem_tmp.i.0 = select bool %tmp.4.i, int* %mem_tmp.1, int* %mem_tmp.0 ; <int*> [#uses=1]
%tmp.3 = load int* %mem_tmp.i.0 ; <int> [#uses=1]
ret int %tmp.3
define i32 @main() {
%mem_tmp.0 = alloca i32 ; <i32*> [#uses=3]
%mem_tmp.1 = alloca i32 ; <i32*> [#uses=3]
store i32 0, i32* %mem_tmp.0
store i32 1, i32* %mem_tmp.1
%tmp.1.i = load i32* %mem_tmp.1 ; <i32> [#uses=1]
%tmp.3.i = load i32* %mem_tmp.0 ; <i32> [#uses=1]
%tmp.4.i = icmp sle i32 %tmp.1.i, %tmp.3.i ; <i1> [#uses=1]
%mem_tmp.i.0 = select i1 %tmp.4.i, i32* %mem_tmp.1, i32* %mem_tmp.0 ; <i32*> [#uses=1]
%tmp.3 = load i32* %mem_tmp.i.0 ; <i32> [#uses=1]
ret i32 %tmp.3
}

View File

@ -1,16 +1,13 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis
; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis
implementation
int %test(int %X) {
%Arr = alloca [2 x int]
%tmp.0 = getelementptr [2 x int]* %Arr, int 0, int 0
store int 1, int* %tmp.0
%tmp.1 = getelementptr [2 x int]* %Arr, int 0, int 1
store int 2, int* %tmp.1
;; This should turn into a select instruction.
%tmp.3 = getelementptr [2 x int]* %Arr, int 0, int %X
%tmp.4 = load int* %tmp.3
ret int %tmp.4
define i32 @test(i32 %X) {
%Arr = alloca [2 x i32] ; <[2 x i32]*> [#uses=3]
%tmp.0 = getelementptr [2 x i32]* %Arr, i32 0, i32 0 ; <i32*> [#uses=1]
store i32 1, i32* %tmp.0
%tmp.1 = getelementptr [2 x i32]* %Arr, i32 0, i32 1 ; <i32*> [#uses=1]
store i32 2, i32* %tmp.1
%tmp.3 = getelementptr [2 x i32]* %Arr, i32 0, i32 %X ; <i32*> [#uses=1]
%tmp.4 = load i32* %tmp.3 ; <i32> [#uses=1]
ret i32 %tmp.4
}

View File

@ -1,14 +1,13 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | \
; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | \
; RUN: not grep alloca
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | \
; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | \
; RUN: grep {bitcast.*float.*i32}
implementation
int %test(float %X) {
%X_addr = alloca float
store float %X, float* %X_addr
%X_addr = bitcast float* %X_addr to int*
%tmp = load int* %X_addr
ret int %tmp
define i32 @test(float %X) {
%X_addr = alloca float ; <float*> [#uses=2]
store float %X, float* %X_addr
%X_addr.upgrd.1 = bitcast float* %X_addr to i32* ; <i32*> [#uses=1]
%tmp = load i32* %X_addr.upgrd.1 ; <i32> [#uses=1]
ret i32 %tmp
}

View File

@ -1,14 +1,13 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | \
; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | \
; RUN: not grep alloca
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | \
; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | \
; RUN: grep bitcast
target endian = little
<4 x int> %test(<4 x float> %X) {
%X_addr = alloca <4 x float>
store <4 x float> %X, <4 x float>* %X_addr
%X_addr = bitcast <4 x float>* %X_addr to <4 x int>*
%tmp = load <4 x int>* %X_addr
ret <4 x int> %tmp
define <4 x i32> @test(<4 x float> %X) {
%X_addr = alloca <4 x float> ; <<4 x float>*> [#uses=2]
store <4 x float> %X, <4 x float>* %X_addr
%X_addr.upgrd.1 = bitcast <4 x float>* %X_addr to <4 x i32>* ; <<4 x i32>*> [#uses=1]
%tmp = load <4 x i32>* %X_addr.upgrd.1 ; <<4 x i32>> [#uses=1]
ret <4 x i32> %tmp
}

View File

@ -1,46 +1,41 @@
; PR892
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | \
; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | \
; RUN: not grep alloca
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | grep {ret i8}
; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | grep {ret i8}
target endian = little
target pointersize = 32
target datalayout = "e-p:32:32"
target triple = "i686-apple-darwin8.7.2"
%struct.Val = type { int*, int }
%struct.Val = type { i32*, i32 }
implementation ; Functions:
sbyte* %test(short* %X) {
%X_addr = alloca short*
store short* %X, short** %X_addr
%X_addr = cast short** %X_addr to sbyte**
%tmp = load sbyte** %X_addr
ret sbyte* %tmp
define i8* @test(i16* %X) {
%X_addr = alloca i16* ; <i16**> [#uses=2]
store i16* %X, i16** %X_addr
%X_addr.upgrd.1 = bitcast i16** %X_addr to i8** ; <i8**> [#uses=1]
%tmp = load i8** %X_addr.upgrd.1 ; <i8*> [#uses=1]
ret i8* %tmp
}
void %test2(long %Op.0) {
%tmp = alloca %struct.Val, align 8
%tmp1 = alloca %struct.Val, align 8
%tmp = call ulong %_Z3foov( )
%tmp1 = cast %struct.Val* %tmp1 to ulong*
store ulong %tmp, ulong* %tmp1
%tmp = getelementptr %struct.Val* %tmp, int 0, uint 0
%tmp2 = getelementptr %struct.Val* %tmp1, int 0, uint 0
%tmp = load int** %tmp2
store int* %tmp, int** %tmp
%tmp3 = getelementptr %struct.Val* %tmp, int 0, uint 1
%tmp4 = getelementptr %struct.Val* %tmp1, int 0, uint 1
%tmp = load int* %tmp4
store int %tmp, int* %tmp3
%tmp7 = cast %struct.Val* %tmp to { long }*
%tmp8 = getelementptr { long }* %tmp7, int 0, uint 0
%tmp9 = load long* %tmp8
call void %_Z3bar3ValS_( long %Op.0, long %tmp9 )
ret void
define void @test2(i64 %Op.0) {
%tmp = alloca %struct.Val, align 8 ; <%struct.Val*> [#uses=3]
%tmp1 = alloca %struct.Val, align 8 ; <%struct.Val*> [#uses=3]
%tmp.upgrd.2 = call i64 @_Z3foov( ) ; <i64> [#uses=1]
%tmp1.upgrd.3 = bitcast %struct.Val* %tmp1 to i64* ; <i64*> [#uses=1]
store i64 %tmp.upgrd.2, i64* %tmp1.upgrd.3
%tmp.upgrd.4 = getelementptr %struct.Val* %tmp, i32 0, i32 0 ; <i32**> [#uses=1]
%tmp2 = getelementptr %struct.Val* %tmp1, i32 0, i32 0 ; <i32**> [#uses=1]
%tmp.upgrd.5 = load i32** %tmp2 ; <i32*> [#uses=1]
store i32* %tmp.upgrd.5, i32** %tmp.upgrd.4
%tmp3 = getelementptr %struct.Val* %tmp, i32 0, i32 1 ; <i32*> [#uses=1]
%tmp4 = getelementptr %struct.Val* %tmp1, i32 0, i32 1 ; <i32*> [#uses=1]
%tmp.upgrd.6 = load i32* %tmp4 ; <i32> [#uses=1]
store i32 %tmp.upgrd.6, i32* %tmp3
%tmp7 = bitcast %struct.Val* %tmp to { i64 }* ; <{ i64 }*> [#uses=1]
%tmp8 = getelementptr { i64 }* %tmp7, i32 0, i32 0 ; <i64*> [#uses=1]
%tmp9 = load i64* %tmp8 ; <i64> [#uses=1]
call void @_Z3bar3ValS_( i64 %Op.0, i64 %tmp9 )
ret void
}
declare ulong %_Z3foov()
declare void %_Z3bar3ValS_(long, long)
declare i64 @_Z3foov()
declare void @_Z3bar3ValS_(i64, i64)

View File

@ -1,55 +1,55 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | \
; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | \
; RUN: not grep alloca
; END.
void %test(<4 x float>* %F, float %f) {
define void @test(<4 x float>* %F, float %f) {
entry:
%G = alloca <4 x float>, align 16 ; <<4 x float>*> [#uses=3]
%tmp = load <4 x float>* %F ; <<4 x float>> [#uses=2]
%tmp3 = add <4 x float> %tmp, %tmp ; <<4 x float>> [#uses=1]
store <4 x float> %tmp3, <4 x float>* %G
%G = getelementptr <4 x float>* %G, int 0, int 0 ; <float*> [#uses=1]
store float %f, float* %G
%tmp4 = load <4 x float>* %G ; <<4 x float>> [#uses=2]
%tmp6 = add <4 x float> %tmp4, %tmp4 ; <<4 x float>> [#uses=1]
store <4 x float> %tmp6, <4 x float>* %F
ret void
%G = alloca <4 x float>, align 16 ; <<4 x float>*> [#uses=3]
%tmp = load <4 x float>* %F ; <<4 x float>> [#uses=2]
%tmp3 = add <4 x float> %tmp, %tmp ; <<4 x float>> [#uses=1]
store <4 x float> %tmp3, <4 x float>* %G
%G.upgrd.1 = getelementptr <4 x float>* %G, i32 0, i32 0 ; <float*> [#uses=1]
store float %f, float* %G.upgrd.1
%tmp4 = load <4 x float>* %G ; <<4 x float>> [#uses=2]
%tmp6 = add <4 x float> %tmp4, %tmp4 ; <<4 x float>> [#uses=1]
store <4 x float> %tmp6, <4 x float>* %F
ret void
}
void %test2(<4 x float>* %F, float %f) {
define void @test2(<4 x float>* %F, float %f) {
entry:
%G = alloca <4 x float>, align 16 ; <<4 x float>*> [#uses=3]
%tmp = load <4 x float>* %F ; <<4 x float>> [#uses=2]
%tmp3 = add <4 x float> %tmp, %tmp ; <<4 x float>> [#uses=1]
store <4 x float> %tmp3, <4 x float>* %G
%tmp = getelementptr <4 x float>* %G, int 0, int 2 ; <float*> [#uses=1]
store float %f, float* %tmp
%tmp4 = load <4 x float>* %G ; <<4 x float>> [#uses=2]
%tmp6 = add <4 x float> %tmp4, %tmp4 ; <<4 x float>> [#uses=1]
store <4 x float> %tmp6, <4 x float>* %F
ret void
%G = alloca <4 x float>, align 16 ; <<4 x float>*> [#uses=3]
%tmp = load <4 x float>* %F ; <<4 x float>> [#uses=2]
%tmp3 = add <4 x float> %tmp, %tmp ; <<4 x float>> [#uses=1]
store <4 x float> %tmp3, <4 x float>* %G
%tmp.upgrd.2 = getelementptr <4 x float>* %G, i32 0, i32 2 ; <float*> [#uses=1]
store float %f, float* %tmp.upgrd.2
%tmp4 = load <4 x float>* %G ; <<4 x float>> [#uses=2]
%tmp6 = add <4 x float> %tmp4, %tmp4 ; <<4 x float>> [#uses=1]
store <4 x float> %tmp6, <4 x float>* %F
ret void
}
void %test3(<4 x float>* %F, float* %f) {
define void @test3(<4 x float>* %F, float* %f) {
entry:
%G = alloca <4 x float>, align 16 ; <<4 x float>*> [#uses=2]
%tmp = load <4 x float>* %F ; <<4 x float>> [#uses=2]
%tmp3 = add <4 x float> %tmp, %tmp ; <<4 x float>> [#uses=1]
store <4 x float> %tmp3, <4 x float>* %G
%tmp = getelementptr <4 x float>* %G, int 0, int 2 ; <float*> [#uses=1]
%tmp = load float* %tmp ; <float> [#uses=1]
store float %tmp, float* %f
ret void
%G = alloca <4 x float>, align 16 ; <<4 x float>*> [#uses=2]
%tmp = load <4 x float>* %F ; <<4 x float>> [#uses=2]
%tmp3 = add <4 x float> %tmp, %tmp ; <<4 x float>> [#uses=1]
store <4 x float> %tmp3, <4 x float>* %G
%tmp.upgrd.3 = getelementptr <4 x float>* %G, i32 0, i32 2 ; <float*> [#uses=1]
%tmp.upgrd.4 = load float* %tmp.upgrd.3 ; <float> [#uses=1]
store float %tmp.upgrd.4, float* %f
ret void
}
void %test4(<4 x float>* %F, float* %f) {
define void @test4(<4 x float>* %F, float* %f) {
entry:
%G = alloca <4 x float>, align 16 ; <<4 x float>*> [#uses=2]
%tmp = load <4 x float>* %F ; <<4 x float>> [#uses=2]
%tmp3 = add <4 x float> %tmp, %tmp ; <<4 x float>> [#uses=1]
store <4 x float> %tmp3, <4 x float>* %G
%G = getelementptr <4 x float>* %G, int 0, int 0 ; <float*> [#uses=1]
%tmp = load float* %G ; <float> [#uses=1]
store float %tmp, float* %f
ret void
%G = alloca <4 x float>, align 16 ; <<4 x float>*> [#uses=2]
%tmp = load <4 x float>* %F ; <<4 x float>> [#uses=2]
%tmp3 = add <4 x float> %tmp, %tmp ; <<4 x float>> [#uses=1]
store <4 x float> %tmp3, <4 x float>* %G
%G.upgrd.5 = getelementptr <4 x float>* %G, i32 0, i32 0 ; <float*> [#uses=1]
%tmp.upgrd.6 = load float* %G.upgrd.5 ; <float> [#uses=1]
store float %tmp.upgrd.6, float* %f
ret void
}