summaryrefslogtreecommitdiff
path: root/test/Transforms/SCCP
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms/SCCP')
-rw-r--r--test/Transforms/SCCP/crash.ll24
-rw-r--r--test/Transforms/SCCP/ipsccp-basic.ll72
-rw-r--r--test/Transforms/SCCP/loadtest.ll11
3 files changed, 104 insertions, 3 deletions
diff --git a/test/Transforms/SCCP/crash.ll b/test/Transforms/SCCP/crash.ll
new file mode 100644
index 0000000000000..e34eacae84459
--- /dev/null
+++ b/test/Transforms/SCCP/crash.ll
@@ -0,0 +1,24 @@
+; RUN: opt %s -sccp -S
+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"
+target triple = "x86_64-apple-darwin10.0"
+
+define void @test1(i8 %arg) {
+entry:
+ br i1 undef, label %return, label %bb
+
+bb:
+ br label %bb34
+
+bb23:
+ %c = icmp eq i8 %arg, undef
+ br i1 %c, label %bb34, label %bb23
+
+bb34:
+ %Kind.1 = phi i32 [ undef, %bb ], [ %ins174, %bb23 ]
+ %mask173 = or i32 %Kind.1, 7
+ %ins174 = and i32 %mask173, -249
+ br label %bb23
+
+return:
+ ret void
+}
diff --git a/test/Transforms/SCCP/ipsccp-basic.ll b/test/Transforms/SCCP/ipsccp-basic.ll
index d3584d1b3ce72..e3699209a35bf 100644
--- a/test/Transforms/SCCP/ipsccp-basic.ll
+++ b/test/Transforms/SCCP/ipsccp-basic.ll
@@ -127,10 +127,80 @@ B:
; CHECK: define i64 @test5b()
; CHECK: A:
; CHECK-NEXT: %c = call i64 @test5c(%0 %a)
-; CHECK-NEXT: ret i64 %c
+; CHECK-NEXT: ret i64 5
define internal i64 @test5c({i64,i64} %a) {
%b = extractvalue {i64,i64} %a, 0
ret i64 %b
}
+
+;;======================== test6
+
+define i64 @test6a() {
+ ret i64 0
+}
+
+define i64 @test6b() {
+ %a = call i64 @test6a()
+ ret i64 %a
+}
+; CHECK: define i64 @test6b
+; CHECK: ret i64 0
+
+;;======================== test7
+
+
+%T = type {i32,i32}
+
+define internal {i32, i32} @test7a(i32 %A) {
+ %X = add i32 1, %A
+ %mrv0 = insertvalue %T undef, i32 %X, 0
+ %mrv1 = insertvalue %T %mrv0, i32 %A, 1
+ ret %T %mrv1
+; CHECK: @test7a
+; CHECK-NEXT: %mrv0 = insertvalue %T undef, i32 18, 0
+; CHECK-NEXT: %mrv1 = insertvalue %T %mrv0, i32 17, 1
+}
+
+define i32 @test7b() {
+ %X = call {i32, i32} @test7a(i32 17)
+ %Y = extractvalue {i32, i32} %X, 0
+ %Z = add i32 %Y, %Y
+ ret i32 %Z
+; CHECK: define i32 @test7b
+; CHECK-NEXT: call %T @test7a(i32 17)
+; CHECK-NEXT: ret i32 36
+}
+
+;;======================== test8
+
+
+define internal {} @test8a(i32 %A, i32* %P) {
+ store i32 %A, i32* %P
+ ret {} {}
+; CHECK: @test8a
+; CHECK-NEXT: store i32 5,
+; CHECK-NEXT: ret
+}
+
+define void @test8b(i32* %P) {
+ %X = call {} @test8a(i32 5, i32* %P)
+ ret void
+; CHECK: define void @test8b
+; CHECK-NEXT: call { } @test8a
+; CHECK-NEXT: ret void
+}
+
+;;======================== test9
+
+@test9g = internal global { } zeroinitializer
+
+define void @test9() {
+entry:
+ %local_foo = alloca { }
+ load { }* @test9g
+ store { } %0, { }* %local_foo
+ ret void
+}
+
diff --git a/test/Transforms/SCCP/loadtest.ll b/test/Transforms/SCCP/loadtest.ll
index fd82aef821ff6..add2af483f560 100644
--- a/test/Transforms/SCCP/loadtest.ll
+++ b/test/Transforms/SCCP/loadtest.ll
@@ -1,5 +1,6 @@
; This test makes sure that these instructions are properly constant propagated.
-;
+
+target datalayout = "e-p:32:32"
; RUN: opt < %s -sccp -S | not grep load
@@ -20,7 +21,13 @@ define float @test2() {
define i32 @test3() {
%A = getelementptr [2 x { i32, float }]* @Y, i64 0, i64 0, i32 0 ; <i32*> [#uses=1]
- %B = load i32* %A ; <i32> [#uses=1]
+ %B = load i32* %A
ret i32 %B
}
+define i8 @test4() {
+ %A = bitcast i32* @X to i8*
+ %B = load i8* %A
+ ret i8 %B
+}
+