summaryrefslogtreecommitdiffstats
path: root/test/Transforms/ScalarRepl
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2011-02-20 12:57:14 +0000
committerdim <dim@FreeBSD.org>2011-02-20 12:57:14 +0000
commitcbb70ce070d220642b038ea101d9c0f9fbf860d6 (patch)
treed2b61ce94e654cb01a254d2195259db5f9cc3f3c /test/Transforms/ScalarRepl
parent4ace901e87dac5bbbac78ed325e75462e48e386e (diff)
downloadFreeBSD-src-cbb70ce070d220642b038ea101d9c0f9fbf860d6.zip
FreeBSD-src-cbb70ce070d220642b038ea101d9c0f9fbf860d6.tar.gz
Vendor import of llvm trunk r126079:
http://llvm.org/svn/llvm-project/llvm/trunk@126079
Diffstat (limited to 'test/Transforms/ScalarRepl')
-rw-r--r--test/Transforms/ScalarRepl/2003-05-30-InvalidIndices.ll8
-rw-r--r--test/Transforms/ScalarRepl/2003-05-30-MultiLevel.ll10
-rw-r--r--test/Transforms/ScalarRepl/2005-12-14-UnionPromoteCrash.ll28
-rw-r--r--test/Transforms/ScalarRepl/2006-01-24-IllegalUnionPromoteCrash.ll12
-rw-r--r--test/Transforms/ScalarRepl/2006-04-20-PromoteCrash.ll18
-rw-r--r--test/Transforms/ScalarRepl/2006-10-23-PointerUnionCrash.ll57
-rw-r--r--test/Transforms/ScalarRepl/2006-12-11-SROA-Crash.ll20
-rw-r--r--test/Transforms/ScalarRepl/2007-03-19-CanonicalizeMemcpy.ll44
-rw-r--r--test/Transforms/ScalarRepl/2009-01-09-scalarrepl-empty.ll15
-rw-r--r--test/Transforms/ScalarRepl/2009-04-21-ZeroLengthMemSet.ll16
-rw-r--r--test/Transforms/ScalarRepl/2009-05-08-I1Crash.ll12
-rw-r--r--test/Transforms/ScalarRepl/2009-06-01-BitcastIntPadding.ll17
-rw-r--r--test/Transforms/ScalarRepl/2009-08-16-VLA.ll23
-rw-r--r--test/Transforms/ScalarRepl/basictest.ll23
-rw-r--r--test/Transforms/ScalarRepl/copy-aggregate.ll52
-rw-r--r--test/Transforms/ScalarRepl/crash.ll260
-rw-r--r--test/Transforms/ScalarRepl/memcpy-from-global.ll66
-rw-r--r--test/Transforms/ScalarRepl/phi-select.ll153
-rw-r--r--test/Transforms/ScalarRepl/vector_promote.ll6
19 files changed, 551 insertions, 289 deletions
diff --git a/test/Transforms/ScalarRepl/2003-05-30-InvalidIndices.ll b/test/Transforms/ScalarRepl/2003-05-30-InvalidIndices.ll
deleted file mode 100644
index b147ec9..0000000
--- a/test/Transforms/ScalarRepl/2003-05-30-InvalidIndices.ll
+++ /dev/null
@@ -1,8 +0,0 @@
-; RUN: opt < %s -scalarrepl
-
-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
-}
-
diff --git a/test/Transforms/ScalarRepl/2003-05-30-MultiLevel.ll b/test/Transforms/ScalarRepl/2003-05-30-MultiLevel.ll
deleted file mode 100644
index 89c0b05..0000000
--- a/test/Transforms/ScalarRepl/2003-05-30-MultiLevel.ll
+++ /dev/null
@@ -1,10 +0,0 @@
-; RUN: opt < %s -scalarrepl
-
-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
-}
-
diff --git a/test/Transforms/ScalarRepl/2005-12-14-UnionPromoteCrash.ll b/test/Transforms/ScalarRepl/2005-12-14-UnionPromoteCrash.ll
deleted file mode 100644
index ea23c31..0000000
--- a/test/Transforms/ScalarRepl/2005-12-14-UnionPromoteCrash.ll
+++ /dev/null
@@ -1,28 +0,0 @@
-; RUN: opt < %s -scalarrepl -disable-output
-
-target datalayout = "E-p:32:32"
- %struct.rtx_def = type { [2 x i8], i32, [1 x %union.rtunion_def] }
- %union.rtunion_def = type { i32 }
-
-define void @find_reloads() {
-entry:
- %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 i1 false, label %then.4, label %switchexit.0
-then.4: ; preds = %label.7
- %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
-}
-
diff --git a/test/Transforms/ScalarRepl/2006-01-24-IllegalUnionPromoteCrash.ll b/test/Transforms/ScalarRepl/2006-01-24-IllegalUnionPromoteCrash.ll
deleted file mode 100644
index 03c7452..0000000
--- a/test/Transforms/ScalarRepl/2006-01-24-IllegalUnionPromoteCrash.ll
+++ /dev/null
@@ -1,12 +0,0 @@
-; RUN: opt < %s -scalarrepl -disable-output
-
-target datalayout = "E-p:32:32"
-
-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
-}
-
diff --git a/test/Transforms/ScalarRepl/2006-04-20-PromoteCrash.ll b/test/Transforms/ScalarRepl/2006-04-20-PromoteCrash.ll
deleted file mode 100644
index 63840f1..0000000
--- a/test/Transforms/ScalarRepl/2006-04-20-PromoteCrash.ll
+++ /dev/null
@@ -1,18 +0,0 @@
-; RUN: opt < %s -scalarrepl -disable-output
-
-define void @output_toc() {
-entry:
- %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()
-
diff --git a/test/Transforms/ScalarRepl/2006-10-23-PointerUnionCrash.ll b/test/Transforms/ScalarRepl/2006-10-23-PointerUnionCrash.ll
deleted file mode 100644
index dcd7e53..0000000
--- a/test/Transforms/ScalarRepl/2006-10-23-PointerUnionCrash.ll
+++ /dev/null
@@ -1,57 +0,0 @@
-; RUN: opt < %s -scalarrepl -disable-output
-; END.
-target datalayout = "e-p:32:32"
-target triple = "i686-apple-darwin8.7.2"
-
-define void @glgProcessColor() {
-entry:
- %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 i1 false, label %bb1365, label %bb27055
-bb1365: ; preds = %bb1357
- 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 = bitcast i8** %source_ptr to i8** ; <i8**> [#uses=1]
- %tmp9885 = load i8** %source_ptr9884 ; <i8*> [#uses=0]
- ret void
-bb10249: ; preds = %bb1365
- %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
-}
diff --git a/test/Transforms/ScalarRepl/2006-12-11-SROA-Crash.ll b/test/Transforms/ScalarRepl/2006-12-11-SROA-Crash.ll
deleted file mode 100644
index 2606203..0000000
--- a/test/Transforms/ScalarRepl/2006-12-11-SROA-Crash.ll
+++ /dev/null
@@ -1,20 +0,0 @@
-; RUN: opt < %s -scalarrepl -disable-output
-; PR1045
-
-target datalayout = "e-p:32: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 { i8 }
- %"struct.__gnu_cxx::bitmap_allocator<char>::_Alloc_block" = type { [8 x i8] }
-
-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.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
-}
diff --git a/test/Transforms/ScalarRepl/2007-03-19-CanonicalizeMemcpy.ll b/test/Transforms/ScalarRepl/2007-03-19-CanonicalizeMemcpy.ll
deleted file mode 100644
index bd49106..0000000
--- a/test/Transforms/ScalarRepl/2007-03-19-CanonicalizeMemcpy.ll
+++ /dev/null
@@ -1,44 +0,0 @@
-; RUN: opt < %s -scalarrepl -disable-output
-
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:64:64-v128:128:128-a0:0:64"
-target triple = "arm-apple-darwin8"
- %struct.CGPoint = type { float, float }
- %struct.aal_big_range_t = type { i32, i32 }
- %struct.aal_callback_t = type { i8* (i8*, i32)*, void (i8*, i8*)* }
- %struct.aal_edge_pool_t = type { %struct.aal_edge_pool_t*, i32, i32, [0 x %struct.aal_edge_t] }
- %struct.aal_edge_t = type { %struct.CGPoint, %struct.CGPoint, i32 }
- %struct.aal_range_t = type { i16, i16 }
- %struct.aal_span_pool_t = type { %struct.aal_span_pool_t*, [341 x %struct.aal_span_t] }
- %struct.aal_span_t = type { %struct.aal_span_t*, %struct.aal_big_range_t }
- %struct.aal_spanarray_t = type { [2 x %struct.aal_range_t] }
- %struct.aal_spanbucket_t = type { i16, [2 x i8], %struct.anon }
- %struct.aal_state_t = type { %struct.CGPoint, %struct.CGPoint, %struct.CGPoint, i32, float, float, float, float, %struct.CGPoint, %struct.CGPoint, float, float, float, float, i32, i32, i32, i32, float, float, i8*, i32, i32, %struct.aal_edge_pool_t*, %struct.aal_edge_pool_t*, i8*, %struct.aal_callback_t*, i32, %struct.aal_span_t*, %struct.aal_span_t*, %struct.aal_span_t*, %struct.aal_span_pool_t*, i8, float, i8, i32 }
- %struct.anon = type { %struct.aal_spanarray_t }
-
-
-declare void @llvm.memcpy.i32(i8*, i8*, i32, i32)
-
-define fastcc void @aal_insert_span() {
-entry:
- %SB = alloca %struct.aal_spanbucket_t, align 4 ; <%struct.aal_spanbucket_t*> [#uses=2]
- br i1 false, label %cond_true, label %cond_next79
-
-cond_true: ; preds = %entry
- br i1 false, label %cond_next, label %cond_next114.i
-
-cond_next114.i: ; preds = %cond_true
- ret void
-
-cond_next: ; preds = %cond_true
- %SB19 = bitcast %struct.aal_spanbucket_t* %SB to i8* ; <i8*> [#uses=1]
- call void @llvm.memcpy.i32( i8* %SB19, i8* null, i32 12, i32 0 )
- br i1 false, label %cond_next34, label %cond_next79
-
-cond_next34: ; preds = %cond_next
- %i.2.reload22 = load i32* null ; <i32> [#uses=1]
- %tmp51 = getelementptr %struct.aal_spanbucket_t* %SB, i32 0, i32 2, i32 0, i32 0, i32 %i.2.reload22, i32 1 ; <i16*> [#uses=0]
- ret void
-
-cond_next79: ; preds = %cond_next, %entry
- ret void
-}
diff --git a/test/Transforms/ScalarRepl/2009-01-09-scalarrepl-empty.ll b/test/Transforms/ScalarRepl/2009-01-09-scalarrepl-empty.ll
deleted file mode 100644
index 62f7d19..0000000
--- a/test/Transforms/ScalarRepl/2009-01-09-scalarrepl-empty.ll
+++ /dev/null
@@ -1,15 +0,0 @@
-; RUN: opt < %s -scalarrepl | llvm-dis
-; PR3304
-
- %struct.c37304a__vrec = type { i8, %struct.c37304a__vrec___disc___XVN }
- %struct.c37304a__vrec___disc___XVN = type {
-%struct.c37304a__vrec___disc___XVN___O }
- %struct.c37304a__vrec___disc___XVN___O = type { }
-
-define void @_ada_c37304a() {
-entry:
- %v = alloca %struct.c37304a__vrec
- %0 = getelementptr %struct.c37304a__vrec* %v, i32 0, i32 0
- store i8 8, i8* %0, align 1
- unreachable
-}
diff --git a/test/Transforms/ScalarRepl/2009-04-21-ZeroLengthMemSet.ll b/test/Transforms/ScalarRepl/2009-04-21-ZeroLengthMemSet.ll
deleted file mode 100644
index c5ebf8e..0000000
--- a/test/Transforms/ScalarRepl/2009-04-21-ZeroLengthMemSet.ll
+++ /dev/null
@@ -1,16 +0,0 @@
-; RUN: opt < %s -scalarrepl | llvm-dis
-; rdar://6808691
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
-target triple = "x86_64-apple-darwin9.0"
- type <{ i32, i16, i8, i8, i64, i64, i16, [0 x i16] }>
-
-define i32 @foo() {
-entry:
- %.compoundliteral = alloca %0
- %tmp228 = getelementptr %0* %.compoundliteral, i32 0, i32 7
- %tmp229 = bitcast [0 x i16]* %tmp228 to i8*
- call void @llvm.memset.i64(i8* %tmp229, i8 0, i64 0, i32 2)
- unreachable
-}
-
-declare void @llvm.memset.i64(i8* nocapture, i8, i64, i32) nounwind
diff --git a/test/Transforms/ScalarRepl/2009-05-08-I1Crash.ll b/test/Transforms/ScalarRepl/2009-05-08-I1Crash.ll
deleted file mode 100644
index aa3487b..0000000
--- a/test/Transforms/ScalarRepl/2009-05-08-I1Crash.ll
+++ /dev/null
@@ -1,12 +0,0 @@
-; RUN: opt < %s -scalarrepl | llvm-dis
-; PR4146
-
- %wrapper = type { i1 }
-
-define void @f() {
-entry:
- %w = alloca %wrapper, align 8 ; <%wrapper*> [#uses=1]
- %0 = getelementptr %wrapper* %w, i64 0, i32 0 ; <i1*>
- store i1 true, i1* %0
- ret void
-}
diff --git a/test/Transforms/ScalarRepl/2009-06-01-BitcastIntPadding.ll b/test/Transforms/ScalarRepl/2009-06-01-BitcastIntPadding.ll
deleted file mode 100644
index cecbdd4..0000000
--- a/test/Transforms/ScalarRepl/2009-06-01-BitcastIntPadding.ll
+++ /dev/null
@@ -1,17 +0,0 @@
-; RUN: opt < %s -scalarrepl
-; PR4286
-
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
-target triple = "x86_64-undermydesk-freebsd8.0"
- %struct.singlebool = type <{ i8 }>
-
-define zeroext i8 @doit() nounwind {
-entry:
- %a = alloca %struct.singlebool, align 1 ; <%struct.singlebool*> [#uses=2]
- %storetmp.i = bitcast %struct.singlebool* %a to i1* ; <i1*> [#uses=1]
- store i1 true, i1* %storetmp.i
- %tmp = getelementptr %struct.singlebool* %a, i64 0, i32 0 ; <i8*> [#uses=1]
- %tmp1 = load i8* %tmp ; <i8> [#uses=1]
- ret i8 %tmp1
-}
-
diff --git a/test/Transforms/ScalarRepl/2009-08-16-VLA.ll b/test/Transforms/ScalarRepl/2009-08-16-VLA.ll
deleted file mode 100644
index d69af11..0000000
--- a/test/Transforms/ScalarRepl/2009-08-16-VLA.ll
+++ /dev/null
@@ -1,23 +0,0 @@
-; RUN: opt < %s -scalarrepl -disable-opt
-
- %struct.Item = type { [4 x i16], %struct.rule* }
- %struct.rule = type { [4 x i16], i32, i32, i32, %struct.nonterminal*, %struct.pattern*, i8 }
- %struct.nonterminal = type { i8*, i32, i32, i32, %struct.plankMap*, %struct.rule* }
- %struct.plankMap = type { %struct.list*, i32, %struct.stateMap* }
- %struct.list = type { i8*, %struct.list* }
- %struct.stateMap = type { i8*, %struct.plank*, i32, i16* }
- %struct.plank = type { i8*, %struct.list*, i32 }
- %struct.pattern = type { %struct.nonterminal*, %struct.operator*, [2 x %struct.nonterminal*] }
- %struct.operator = type { i8*, i8, i32, i32, i32, i32, %struct.table* }
- %struct.table = type { %struct.operator*, %struct.list*, i16*, [2 x %struct.dimension*], %struct.item_set** }
- %struct.dimension = type { i16*, %struct.Index_Map, %struct.mapping*, i32, %struct.plankMap* }
- %struct.Index_Map = type { i32, %struct.item_set** }
- %struct.item_set = type { i32, i32, %struct.operator*, [2 x %struct.item_set*], %struct.item_set*, i16*, %struct.Item*, %struct.Item* }
- %struct.mapping = type { %struct.list**, i32, i32, i32, %struct.item_set** }
-
-define void @addHP_2_0() {
-bb4.i:
- %0 = malloc [0 x %struct.Item] ; <[0 x %struct.Item]*> [#uses=1]
- %.sub.i.c.i = getelementptr [0 x %struct.Item]* %0, i32 0, i32 0 ; <%struct.Item*> [#uses=0]
- unreachable
-}
diff --git a/test/Transforms/ScalarRepl/basictest.ll b/test/Transforms/ScalarRepl/basictest.ll
index a26b62d..9676873 100644
--- a/test/Transforms/ScalarRepl/basictest.ll
+++ b/test/Transforms/ScalarRepl/basictest.ll
@@ -1,11 +1,30 @@
-; RUN: opt < %s -scalarrepl -mem2reg -S | not grep alloca
+; RUN: opt < %s -scalarrepl -S | FileCheck %s
target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"
-define i32 @test() {
+define i32 @test1() {
%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
+; CHECK: @test1
+; CHECK-NOT: alloca
+; CHECK: ret i32 0
+}
+
+; PR8980
+define i64 @test2(i64 %X) {
+ %A = alloca [8 x i8]
+ %B = bitcast [8 x i8]* %A to i64*
+
+ store i64 %X, i64* %B
+ br label %L2
+
+L2:
+ %Z = load i64* %B ; <i32> [#uses=1]
+ ret i64 %Z
+; CHECK: @test2
+; CHECK-NOT: alloca
+; CHECK: ret i64 %X
}
diff --git a/test/Transforms/ScalarRepl/copy-aggregate.ll b/test/Transforms/ScalarRepl/copy-aggregate.ll
index 2992413..997da4b 100644
--- a/test/Transforms/ScalarRepl/copy-aggregate.ll
+++ b/test/Transforms/ScalarRepl/copy-aggregate.ll
@@ -1,9 +1,11 @@
-; RUN: opt < %s -scalarrepl -S | not grep alloca
+; RUN: opt < %s -scalarrepl -S | FileCheck %s
; PR3290
target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"
;; Store of integer to whole alloca struct.
define i32 @test1(i64 %V) nounwind {
+; CHECK: test1
+; CHECK-NOT: alloca
%X = alloca {{i32, i32}}
%Y = bitcast {{i32,i32}}* %X to i64*
store i64 %V, i64* %Y
@@ -18,6 +20,8 @@ define i32 @test1(i64 %V) nounwind {
;; Store of integer to whole struct/array alloca.
define float @test2(i128 %V) nounwind {
+; CHECK: test2
+; CHECK-NOT: alloca
%X = alloca {[4 x float]}
%Y = bitcast {[4 x float]}* %X to i128*
store i128 %V, i128* %Y
@@ -32,6 +36,8 @@ define float @test2(i128 %V) nounwind {
;; Load of whole alloca struct as integer
define i64 @test3(i32 %a, i32 %b) nounwind {
+; CHECK: test3
+; CHECK-NOT: alloca
%X = alloca {{i32, i32}}
%A = getelementptr {{i32,i32}}* %X, i32 0, i32 0, i32 0
@@ -46,6 +52,8 @@ define i64 @test3(i32 %a, i32 %b) nounwind {
;; load of integer from whole struct/array alloca.
define i128 @test4(float %a, float %b) nounwind {
+; CHECK: test4
+; CHECK-NOT: alloca
%X = alloca {[4 x float]}
%A = getelementptr {[4 x float]}* %X, i32 0, i32 0, i32 0
%B = getelementptr {[4 x float]}* %X, i32 0, i32 0, i32 3
@@ -56,3 +64,45 @@ define i128 @test4(float %a, float %b) nounwind {
%V = load i128* %Y
ret i128 %V
}
+
+;; If the elements of a struct or array alloca contain padding, SROA can still
+;; split up the alloca as long as there is no padding between the elements.
+%padded = type { i16, i8 }
+%arr = type [4 x %padded]
+define void @test5(%arr* %p, %arr* %q) {
+entry:
+; CHECK: test5
+; CHECK-NOT: i128
+ %var = alloca %arr, align 4
+ %vari8 = bitcast %arr* %var to i8*
+ %pi8 = bitcast %arr* %p to i8*
+ call void @llvm.memcpy.p0i8.p0i8.i32(i8* %vari8, i8* %pi8, i32 16, i32 4, i1 false)
+ %qi8 = bitcast %arr* %q to i8*
+ call void @llvm.memcpy.p0i8.p0i8.i32(i8* %qi8, i8* %vari8, i32 16, i32 4, i1 false)
+ ret void
+}
+
+;; Check that an array alloca can be split up when it is also accessed with
+;; a load or store as a homogeneous structure with the same element type and
+;; number of elements as the array.
+%homogeneous = type { <8 x i16>, <8 x i16>, <8 x i16> }
+%wrapped_array = type { [3 x <8 x i16>] }
+define void @test6(i8* %p, %wrapped_array* %arr) {
+entry:
+; CHECK: test6
+; CHECK: store <8 x i16>
+; CHECK: store <8 x i16>
+; CHECK: store <8 x i16>
+ %var = alloca %wrapped_array, align 16
+ %res = call %homogeneous @test6callee(i8* %p)
+ %varcast = bitcast %wrapped_array* %var to %homogeneous*
+ store %homogeneous %res, %homogeneous* %varcast
+ %tmp1 = bitcast %wrapped_array* %arr to i8*
+ %tmp2 = bitcast %wrapped_array* %var to i8*
+ call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp1, i8* %tmp2, i32 48, i32 16, i1 false)
+ ret void
+}
+
+declare %homogeneous @test6callee(i8* nocapture) nounwind
+
+declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
diff --git a/test/Transforms/ScalarRepl/crash.ll b/test/Transforms/ScalarRepl/crash.ll
new file mode 100644
index 0000000..7b62f09
--- /dev/null
+++ b/test/Transforms/ScalarRepl/crash.ll
@@ -0,0 +1,260 @@
+; RUN: opt -scalarrepl %s -disable-output
+; RUN: opt -scalarrepl-ssa %s -disable-output
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-apple-darwin10.0.0"
+
+; PR9017
+define void @test1() nounwind readnone ssp {
+entry:
+ %l_72 = alloca i32*, align 8
+ unreachable
+
+for.cond: ; preds = %for.cond
+ %tmp1.i = load i32** %l_72, align 8
+ store i32* %tmp1.i, i32** %l_72, align 8
+ br label %for.cond
+
+if.end: ; No predecessors!
+ ret void
+}
+
+
+define void @test2() {
+ %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
+}
+
+define i32 @test3() {
+ %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
+}
+
+
+%struct.rtx_def = type { [2 x i8], i32, [1 x %union.rtunion_def] }
+%union.rtunion_def = type { i32 }
+
+define void @test4() {
+entry:
+ %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 i1 false, label %then.4, label %switchexit.0
+then.4: ; preds = %label.7
+ %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
+}
+
+
+define void @test5() {
+entry:
+ %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 i1 false, label %bb1365, label %bb27055
+bb1365: ; preds = %bb1357
+ 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 = bitcast i8** %source_ptr to i8** ; <i8**> [#uses=1]
+ %tmp9885 = load i8** %source_ptr9884 ; <i8*> [#uses=0]
+ ret void
+bb10249: ; preds = %bb1365
+ %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
+}
+
+
+ %"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] }
+
+; PR1045
+define void @test6() {
+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.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
+}
+
+ %struct.CGPoint = type { float, float }
+ %struct.aal_big_range_t = type { i32, i32 } %struct.aal_callback_t = type { i8* (i8*, i32)*, void (i8*, i8*)* } %struct.aal_edge_pool_t = type { %struct.aal_edge_pool_t*, i32, i32, [0 x %struct.aal_edge_t] } %struct.aal_edge_t = type { %struct.CGPoint, %struct.CGPoint, i32 }
+ %struct.aal_range_t = type { i16, i16 }
+ %struct.aal_span_pool_t = type { %struct.aal_span_pool_t*, [341 x %struct.aal_span_t] }
+ %struct.aal_span_t = type { %struct.aal_span_t*, %struct.aal_big_range_t }
+ %struct.aal_spanarray_t = type { [2 x %struct.aal_range_t] }
+ %struct.aal_spanbucket_t = type { i16, [2 x i8], %struct.anon }
+ %struct.aal_state_t = type { %struct.CGPoint, %struct.CGPoint, %struct.CGPoint, i32, float, float, float, float, %struct.CGPoint, %struct.CGPoint, float, float, float, float, i32, i32, i32, i32, float, float, i8*, i32, i32, %struct.aal_edge_pool_t*, %struct.aal_edge_pool_t*, i8*, %struct.aal_callback_t*, i32, %struct.aal_span_t*, %struct.aal_span_t*, %struct.aal_span_t*, %struct.aal_span_pool_t*, i8, float, i8, i32 }
+ %struct.anon = type { %struct.aal_spanarray_t }
+
+
+declare void @llvm.memcpy.i32(i8*, i8*, i32, i32)
+
+define fastcc void @test7() {
+entry:
+ %SB = alloca %struct.aal_spanbucket_t, align 4 ; <%struct.aal_spanbucket_t*> [#uses=2]
+ br i1 false, label %cond_true, label %cond_next79
+
+cond_true: ; preds = %entry
+ br i1 false, label %cond_next, label %cond_next114.i
+
+cond_next114.i: ; preds = %cond_true
+ ret void
+
+cond_next: ; preds = %cond_true
+ %SB19 = bitcast %struct.aal_spanbucket_t* %SB to i8* ; <i8*> [#uses=1]
+ call void @llvm.memcpy.i32( i8* %SB19, i8* null, i32 12, i32 0 )
+ br i1 false, label %cond_next34, label %cond_next79
+
+cond_next34: ; preds = %cond_next
+ %i.2.reload22 = load i32* null ; <i32> [#uses=1]
+ %tmp51 = getelementptr %struct.aal_spanbucket_t* %SB, i32 0, i32 2, i32 0, i32 0, i32 %i.2.reload22, i32 1
+ ; <i16*> [#uses=0]
+ ret void
+
+cond_next79: ; preds = %cond_next, %entry
+ ret void
+}
+
+
+ %struct.c37304a__vrec = type { i8, %struct.c37304a__vrec___disc___XVN }
+ %struct.c37304a__vrec___disc___XVN = type {
+%struct.c37304a__vrec___disc___XVN___O }
+ %struct.c37304a__vrec___disc___XVN___O = type { }
+
+; PR3304
+define void @test8() {
+entry:
+ %v = alloca %struct.c37304a__vrec
+ %0 = getelementptr %struct.c37304a__vrec* %v, i32 0, i32 0
+ store i8 8, i8* %0, align 1
+ unreachable
+}
+
+
+
+; rdar://6808691 - ZeroLengthMemSet
+ type <{ i32, i16, i8, i8, i64, i64, i16, [0 x i16] }>
+
+define i32 @test9() {
+entry:
+ %.compoundliteral = alloca %0
+ %tmp228 = getelementptr %0* %.compoundliteral, i32 0, i32 7
+ %tmp229 = bitcast [0 x i16]* %tmp228 to i8*
+ call void @llvm.memset.i64(i8* %tmp229, i8 0, i64 0, i32 2)
+ unreachable
+}
+
+declare void @llvm.memset.i64(i8* nocapture, i8, i64, i32) nounwind
+
+
+; PR4146 - i1 handling
+%wrapper = type { i1 }
+define void @test10() {
+entry:
+ %w = alloca %wrapper, align 8 ; <%wrapper*> [#uses=1]
+ %0 = getelementptr %wrapper* %w, i64 0, i32 0 ; <i1*>
+ store i1 true, i1* %0
+ ret void
+}
+
+
+ %struct.singlebool = type <{ i8 }>
+; PR4286
+define zeroext i8 @test11() nounwind {
+entry:
+ %a = alloca %struct.singlebool, align 1 ; <%struct.singlebool*> [#uses=2]
+ %storetmp.i = bitcast %struct.singlebool* %a to i1* ; <i1*> [#uses=1]
+ store i1 true, i1* %storetmp.i
+ %tmp = getelementptr %struct.singlebool* %a, i64 0, i32 0 ; <i8*> [#uses=1]
+ %tmp1 = load i8* %tmp ; <i8> [#uses=1]
+ ret i8 %tmp1
+}
+
+
+ %struct.Item = type { [4 x i16], %struct.rule* }
+ %struct.rule = type { [4 x i16], i32, i32, i32, %struct.nonterminal*, %struct.pattern*, i8 }
+ %struct.nonterminal = type { i8*, i32, i32, i32, %struct.plankMap*, %struct.rule* }
+ %struct.plankMap = type { %struct.list*, i32, %struct.stateMap* }
+ %struct.list = type { i8*, %struct.list* }
+ %struct.stateMap = type { i8*, %struct.plank*, i32, i16* }
+ %struct.plank = type { i8*, %struct.list*, i32 }
+ %struct.pattern = type { %struct.nonterminal*, %struct.operator*, [2 x %struct.nonterminal*] }
+ %struct.operator = type { i8*, i8, i32, i32, i32, i32, %struct.table* }
+ %struct.table = type { %struct.operator*, %struct.list*, i16*, [2 x %struct.dimension*], %struct.item_set** }
+ %struct.dimension = type { i16*, %struct.Index_Map, %struct.mapping*, i32, %struct.plankMap* }
+ %struct.Index_Map = type { i32, %struct.item_set** }
+ %struct.item_set = type { i32, i32, %struct.operator*, [2 x %struct.item_set*], %struct.item_set*, i16*, %struct.Item*, %struct.Item* }
+ %struct.mapping = type { %struct.list**, i32, i32, i32, %struct.item_set** }
+
+; VLAs.
+define void @test12() {
+bb4.i:
+ %0 = malloc [0 x %struct.Item] ; <[0 x %struct.Item]*> [#uses=1]
+ %.sub.i.c.i = getelementptr [0 x %struct.Item]* %0, i32 0, i32 0 ; <%struct.Item*> [#uses=0]
+ unreachable
+}
+
+; PR8680
+define void @test13() nounwind {
+entry:
+ %memtmp = alloca i32, align 4
+ %0 = bitcast i32* %memtmp to void ()*
+ call void %0() nounwind
+ ret void
+}
diff --git a/test/Transforms/ScalarRepl/memcpy-from-global.ll b/test/Transforms/ScalarRepl/memcpy-from-global.ll
index 8152785..5b25864 100644
--- a/test/Transforms/ScalarRepl/memcpy-from-global.ll
+++ b/test/Transforms/ScalarRepl/memcpy-from-global.ll
@@ -1,12 +1,19 @@
-; RUN: opt < %s -scalarrepl -S | not grep {call.*memcpy}
+; RUN: opt < %s -scalarrepl -S | FileCheck %s
target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"
@C.0.1248 = internal constant [128 x float] [ float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00 ], align 32 ; <[128 x float]*> [#uses=1]
-define float @grad4(i32 %hash, float %x, float %y, float %z, float %w) {
+define float @test1(i32 %hash, float %x, float %y, float %z, float %w) {
entry:
%lookupTable = alloca [128 x float], align 16 ; <[128 x float]*> [#uses=5]
%lookupTable1 = bitcast [128 x float]* %lookupTable to i8* ; <i8*> [#uses=1]
call void @llvm.memcpy.i32( i8* %lookupTable1, i8* bitcast ([128 x float]* @C.0.1248 to i8*), i32 512, i32 16 )
+
+; CHECK: @test1
+; CHECK-NOT: alloca
+; CHECK-NOT: call{{.*}}@llvm.memcpy
+; CHECK: %lookupTable1 = bitcast [128 x float]* @C.0.1248 to i8*
+; CHECK-NOT: call{{.*}}@llvm.memcpy
+
%tmp3 = shl i32 %hash, 2 ; <i32> [#uses=1]
%tmp5 = and i32 %tmp3, 124 ; <i32> [#uses=4]
%tmp753 = getelementptr [128 x float]* %lookupTable, i32 0, i32 %tmp5 ; <float*> [#uses=1]
@@ -32,3 +39,58 @@ entry:
}
declare void @llvm.memcpy.i32(i8*, i8*, i32, i32)
+
+
+
+declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
+
+%T = type { i8, [123 x i8] }
+
+@G = constant %T {i8 1, [123 x i8] zeroinitializer }
+
+define void @test2() {
+ %A = alloca %T
+ %B = alloca %T
+ %a = bitcast %T* %A to i8*
+ %b = bitcast %T* %B to i8*
+
+; CHECK: @test2
+
+; %A alloca is deleted
+; CHECK-NEXT: %B = alloca %T
+
+; use @G instead of %A
+; CHECK-NEXT: %a = bitcast %T* @G to i8*
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* bitcast (%T* @G to i8*), i64 124, i32 4, i1 false)
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %b, i8* %a, i64 124, i32 4, i1 false)
+ call void @bar(i8* %b)
+ ret void
+}
+
+declare void @bar(i8*)
+
+
+;; Should be able to eliminate the alloca.
+define void @test3() {
+ %A = alloca %T
+ %a = bitcast %T* %A to i8*
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* bitcast (%T* @G to i8*), i64 124, i32 4, i1 false)
+ call void @bar(i8* %a) readonly
+; CHECK: @test3
+; CHECK-NEXT: %a = bitcast %T* @G to i8*
+; CHECK-NEXT: call void @bar(i8* %a)
+ ret void
+}
+
+define void @test4() {
+ %A = alloca %T
+ %a = bitcast %T* %A to i8*
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* bitcast (%T* @G to i8*), i64 124, i32 4, i1 false)
+ call void @baz(i8* byval %a)
+; CHECK: @test4
+; CHECK-NEXT: %a = bitcast %T* @G to i8*
+; CHECK-NEXT: call void @baz(i8* byval %a)
+ ret void
+}
+
+declare void @baz(i8* byval)
diff --git a/test/Transforms/ScalarRepl/phi-select.ll b/test/Transforms/ScalarRepl/phi-select.ll
new file mode 100644
index 0000000..fa3972d
--- /dev/null
+++ b/test/Transforms/ScalarRepl/phi-select.ll
@@ -0,0 +1,153 @@
+; RUN: opt %s -scalarrepl -S | FileCheck %s
+; Test promotion of allocas that have phis and select users.
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-apple-darwin10.2"
+
+%struct.X = type { i32 }
+%PairTy = type {i32, i32}
+
+; CHECK: @test1
+; CHECK: %a.0 = alloca i32
+; CHECK: %b.0 = alloca i32
+define i32 @test1(i32 %x) nounwind readnone ssp {
+entry:
+ %a = alloca %struct.X, align 8 ; <%struct.X*> [#uses=2]
+ %b = alloca %struct.X, align 8 ; <%struct.X*> [#uses=2]
+ %0 = getelementptr inbounds %struct.X* %a, i64 0, i32 0 ; <i32*> [#uses=1]
+ store i32 1, i32* %0, align 8
+ %1 = getelementptr inbounds %struct.X* %b, i64 0, i32 0 ; <i32*> [#uses=1]
+ store i32 2, i32* %1, align 8
+ %2 = icmp eq i32 %x, 0 ; <i1> [#uses=1]
+ %p.0 = select i1 %2, %struct.X* %b, %struct.X* %a ; <%struct.X*> [#uses=1]
+ %3 = getelementptr inbounds %struct.X* %p.0, i64 0, i32 0 ; <i32*> [#uses=1]
+ %4 = load i32* %3, align 8 ; <i32> [#uses=1]
+ ret i32 %4
+}
+
+; CHECK: @test2
+; CHECK: %X.ld = phi i32 [ 1, %entry ], [ 2, %T ]
+; CHECK-NEXT: ret i32 %X.ld
+define i32 @test2(i1 %c) {
+entry:
+ %A = alloca {i32, i32}
+ %B = getelementptr {i32, i32}* %A, i32 0, i32 0
+ store i32 1, i32* %B
+ br i1 %c, label %T, label %F
+T:
+ %C = getelementptr {i32, i32}* %A, i32 0, i32 1
+ store i32 2, i32* %C
+ br label %F
+F:
+ %X = phi i32* [%B, %entry], [%C, %T]
+ %Q = load i32* %X
+ ret i32 %Q
+}
+
+; CHECK: @test3
+; CHECK-NEXT: %Q = select i1 %c, i32 1, i32 2
+; CHECK-NEXT: ret i32 %Q
+; rdar://8904039
+define i32 @test3(i1 %c) {
+ %A = alloca {i32, i32}
+ %B = getelementptr {i32, i32}* %A, i32 0, i32 0
+ store i32 1, i32* %B
+ %C = getelementptr {i32, i32}* %A, i32 0, i32 1
+ store i32 2, i32* %C
+
+ %X = select i1 %c, i32* %B, i32* %C
+ %Q = load i32* %X
+ ret i32 %Q
+}
+
+;; We can't scalarize this, a use of the select is not an element access.
+define i64 @test4(i1 %c) {
+entry:
+ %A = alloca %PairTy
+ ; CHECK: @test4
+ ; CHECK: %A = alloca %PairTy
+ %B = getelementptr {i32, i32}* %A, i32 0, i32 0
+ store i32 1, i32* %B
+ %C = getelementptr {i32, i32}* %A, i32 0, i32 1
+ store i32 2, i32* %B
+
+ %X = select i1 %c, i32* %B, i32* %C
+ %Y = bitcast i32* %X to i64*
+ %Q = load i64* %Y
+ ret i64 %Q
+}
+
+
+;;
+;; Tests for promoting allocas used by selects.
+;; rdar://7339113
+;;
+
+define i32 @test5(i32 *%P) nounwind readnone ssp {
+entry:
+ %b = alloca i32, align 8
+ store i32 2, i32* %b, align 8
+
+ ;; Select on constant condition should be folded.
+ %p.0 = select i1 false, i32* %b, i32* %P
+ store i32 123, i32* %p.0
+
+ %r = load i32* %b, align 8
+ ret i32 %r
+
+; CHECK: @test5
+; CHECK: store i32 123, i32* %P
+; CHECK: ret i32 2
+}
+
+define i32 @test6(i32 %x, i1 %c) nounwind readnone ssp {
+ %a = alloca i32, align 8
+ %b = alloca i32, align 8
+ store i32 1, i32* %a, align 8
+ store i32 2, i32* %b, align 8
+ %p.0 = select i1 %c, i32* %b, i32* %a
+ %r = load i32* %p.0, align 8
+ ret i32 %r
+; CHECK: @test6
+; CHECK-NEXT: %r = select i1 %c, i32 2, i32 1
+; CHECK-NEXT: ret i32 %r
+}
+
+; Verify that the loads happen where the loads are, not where the select is.
+define i32 @test7(i32 %x, i1 %c) nounwind readnone ssp {
+ %a = alloca i32, align 8
+ %b = alloca i32, align 8
+ store i32 1, i32* %a
+ store i32 2, i32* %b
+ %p.0 = select i1 %c, i32* %b, i32* %a
+
+ store i32 0, i32* %a
+
+ %r = load i32* %p.0, align 8
+ ret i32 %r
+; CHECK: @test7
+; CHECK-NOT: alloca i32
+; CHECK: %r = select i1 %c, i32 2, i32 0
+; CHECK: ret i32 %r
+}
+
+;; Promote allocs that are PHI'd together by moving the loads.
+define i32 @test8(i32 %x) nounwind readnone ssp {
+; CHECK: @test8
+; CHECK-NOT: load i32
+; CHECK-NOT: store i32
+; CHECK: %p.0.ld = phi i32 [ 2, %entry ], [ 1, %T ]
+; CHECK-NEXT: ret i32 %p.0.ld
+entry:
+ %a = alloca i32, align 8
+ %b = alloca i32, align 8
+ store i32 1, i32* %a, align 8
+ store i32 2, i32* %b, align 8
+ %c = icmp eq i32 %x, 0
+ br i1 %c, label %T, label %Cont
+T:
+ br label %Cont
+Cont:
+ %p.0 = phi i32* [%b, %entry],[%a, %T]
+ %r = load i32* %p.0, align 8
+ ret i32 %r
+}
diff --git a/test/Transforms/ScalarRepl/vector_promote.ll b/test/Transforms/ScalarRepl/vector_promote.ll
index fe55426..37cb49f 100644
--- a/test/Transforms/ScalarRepl/vector_promote.ll
+++ b/test/Transforms/ScalarRepl/vector_promote.ll
@@ -87,8 +87,6 @@ define i32 @test5(float %X) { ;; should turn into bitcast.
}
-;; should not turn into <1 x i64> - It is a banned MMX datatype.
-;; rdar://8380055
define i64 @test6(<2 x float> %X) {
%X_addr = alloca <2 x float>
store <2 x float> %X, <2 x float>* %X_addr
@@ -96,7 +94,7 @@ define i64 @test6(<2 x float> %X) {
%tmp = load i64* %P
ret i64 %tmp
; CHECK: @test6
-; CHECK-NEXT: bitcast <2 x float> %X to i64
-; CHECK-NEXT: ret i64
+; CHECK: bitcast <2 x float> %X to <1 x i64>
+; CHECK: ret i64
}
OpenPOWER on IntegriCloud