diff options
Diffstat (limited to 'test/Transforms/SCCP')
-rw-r--r-- | test/Transforms/SCCP/2003-08-26-InvokeHandling.ll | 9 | ||||
-rw-r--r-- | test/Transforms/SCCP/2004-11-16-DeadInvoke.ll | 9 | ||||
-rw-r--r-- | test/Transforms/SCCP/2007-05-16-InvokeCrash.ll | 6 | ||||
-rw-r--r-- | test/Transforms/SCCP/2009-01-14-IPSCCP-Invoke.ll | 2 | ||||
-rw-r--r-- | test/Transforms/SCCP/atomic-load-store.ll | 30 | ||||
-rw-r--r-- | test/Transforms/SCCP/ipsccp-basic.ll | 23 | ||||
-rw-r--r-- | test/Transforms/SCCP/switch.ll | 13 | ||||
-rw-r--r-- | test/Transforms/SCCP/undef-resolve.ll | 66 |
8 files changed, 153 insertions, 5 deletions
diff --git a/test/Transforms/SCCP/2003-08-26-InvokeHandling.ll b/test/Transforms/SCCP/2003-08-26-InvokeHandling.ll index 9876375..fb1926e 100644 --- a/test/Transforms/SCCP/2003-08-26-InvokeHandling.ll +++ b/test/Transforms/SCCP/2003-08-26-InvokeHandling.ll @@ -8,11 +8,16 @@ Entry: br i1 %cond, label %Inv, label %Cont Inv: ; preds = %Entry invoke void @foo( ) - to label %Ok unwind label %Cont + to label %Ok unwind label %LPad Ok: ; preds = %Inv br label %Cont +LPad: + %val = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + catch i8* null + br label %Cont Cont: ; preds = %Ok, %Inv, %Entry - %X = phi i32 [ 0, %Entry ], [ 1, %Ok ], [ 0, %Inv ] ; <i32> [#uses=1] + %X = phi i32 [ 0, %Entry ], [ 1, %Ok ], [ 0, %LPad ] ; <i32> [#uses=1] ret i32 %X } +declare i32 @__gxx_personality_v0(...) diff --git a/test/Transforms/SCCP/2004-11-16-DeadInvoke.ll b/test/Transforms/SCCP/2004-11-16-DeadInvoke.ll index 5d2c78e..e7eb101 100644 --- a/test/Transforms/SCCP/2004-11-16-DeadInvoke.ll +++ b/test/Transforms/SCCP/2004-11-16-DeadInvoke.ll @@ -6,8 +6,13 @@ define void @caller() { br i1 true, label %T, label %F F: ; preds = %0 %X = invoke i32 @foo( ) - to label %T unwind label %T ; <i32> [#uses=0] -T: ; preds = %F, %F, %0 + to label %T unwind label %LP ; <i32> [#uses=0] +LP: + %val = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + catch i8* null + br label %T +T: ret void } +declare i32 @__gxx_personality_v0(...) diff --git a/test/Transforms/SCCP/2007-05-16-InvokeCrash.ll b/test/Transforms/SCCP/2007-05-16-InvokeCrash.ll index b84fe6d..a5a42f1 100644 --- a/test/Transforms/SCCP/2007-05-16-InvokeCrash.ll +++ b/test/Transforms/SCCP/2007-05-16-InvokeCrash.ll @@ -31,7 +31,9 @@ bb149: ; preds = %bb114 bb177: ; preds = %bb149 unreachable cleanup: ; preds = %bb149, %bb114, %bb67 - unwind + %val = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + cleanup + resume { i8*, i32 } %val } declare double @sin(double) @@ -39,3 +41,5 @@ declare double @sin(double) declare double @log(double) declare double @sqrt(double) + +declare i32 @__gxx_personality_v0(...) diff --git a/test/Transforms/SCCP/2009-01-14-IPSCCP-Invoke.ll b/test/Transforms/SCCP/2009-01-14-IPSCCP-Invoke.ll index d23ee2b..7546bf5 100644 --- a/test/Transforms/SCCP/2009-01-14-IPSCCP-Invoke.ll +++ b/test/Transforms/SCCP/2009-01-14-IPSCCP-Invoke.ll @@ -7,6 +7,8 @@ define i32 @main() { to label %UnifiedReturnBlock unwind label %lpad lpad: + %val = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + cleanup unreachable UnifiedReturnBlock: diff --git a/test/Transforms/SCCP/atomic-load-store.ll b/test/Transforms/SCCP/atomic-load-store.ll new file mode 100644 index 0000000..09061f0 --- /dev/null +++ b/test/Transforms/SCCP/atomic-load-store.ll @@ -0,0 +1,30 @@ +; RUN: opt < %s -ipsccp -S | FileCheck %s + +; This transformation is safe for atomic loads and stores; check that it works. + +@G = internal global i32 17 +@C = internal constant i32 222 + +define i32 @test1() { + %V = load atomic i32* @G seq_cst, align 4 + %C = icmp eq i32 %V, 17 + br i1 %C, label %T, label %F +T: + store atomic i32 17, i32* @G seq_cst, align 4 + ret i32 %V +F: + store atomic i32 123, i32* @G seq_cst, align 4 + ret i32 0 +} +; CHECK: define i32 @test1 +; CHECK-NOT: store +; CHECK: ret i32 17 + +define i32 @test2() { + %V = load atomic i32* @C seq_cst, align 4 + ret i32 %V +} + +; CHECK: define i32 @test2 +; CHECK-NOT: load +; CHECK: ret i32 222 diff --git a/test/Transforms/SCCP/ipsccp-basic.ll b/test/Transforms/SCCP/ipsccp-basic.ll index b9e3f42..8340f0c 100644 --- a/test/Transforms/SCCP/ipsccp-basic.ll +++ b/test/Transforms/SCCP/ipsccp-basic.ll @@ -90,6 +90,8 @@ A: %c = call i64 @test4c(i64 %b) ret i64 %c B: + %val = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + catch i8* null ret i64 0 } ; CHECK: define i64 @test4b() @@ -121,6 +123,8 @@ A: %c = call i64 @test5c({i64,i64} %a) ret i64 %c B: + %val = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + catch i8* null ret i64 0 } @@ -204,3 +208,22 @@ entry: ret void } +declare i32 @__gxx_personality_v0(...) + +;;======================== test10 + +define i32 @test10a() nounwind { +entry: + %call = call i32 @test10b(i32 undef) + ret i32 %call +; CHECK: define i32 @test10a +; CHECK: ret i32 0 +} + +define internal i32 @test10b(i32 %x) nounwind { +entry: + %r = and i32 %x, 1 + ret i32 %r +; CHECK: define internal i32 @test10b +; CHECK: ret i32 undef +} diff --git a/test/Transforms/SCCP/switch.ll b/test/Transforms/SCCP/switch.ll new file mode 100644 index 0000000..9f93423 --- /dev/null +++ b/test/Transforms/SCCP/switch.ll @@ -0,0 +1,13 @@ +; RUN: opt -S -sccp < %s | FileCheck %s + +; Make sure we always consider the default edge executable for a switch +; with no cases. +declare void @foo() +define void @test1() { +; CHECK: define void @test1 +; CHECK: call void @foo() + switch i32 undef, label %d [] +d: + call void @foo() + ret void +} diff --git a/test/Transforms/SCCP/undef-resolve.ll b/test/Transforms/SCCP/undef-resolve.ll index bed561c..a3dddb7 100644 --- a/test/Transforms/SCCP/undef-resolve.ll +++ b/test/Transforms/SCCP/undef-resolve.ll @@ -104,3 +104,69 @@ bb1.us-lcssa: ; preds = %control bb1: ; preds = %bb1.us-lcssa, %bb1.us-lcssa.us ret i32 0 } + +; Make sure SCCP honors the xor "idiom" +; rdar://9956541 +define i32 @test3() { + %t = xor i32 undef, undef + ret i32 %t +; CHECK: @test3 +; CHECK: ret i32 0 +} + +; Be conservative with FP ops +define double @test4(double %x) { + %t = fadd double %x, undef + ret double %t +; CHECK: @test4 +; CHECK: fadd double %x, undef +} + +; Make sure casts produce a possible value +define i32 @test5() { + %t = sext i8 undef to i32 + ret i32 %t +; CHECK: @test5 +; CHECK: ret i32 0 +} + +; Make sure ashr produces a possible value +define i32 @test6() { + %t = ashr i32 undef, 31 + ret i32 %t +; CHECK: @test6 +; CHECK: ret i32 -1 +} + +; Make sure lshr produces a possible value +define i32 @test7() { + %t = lshr i32 undef, 31 + ret i32 %t +; CHECK: @test7 +; CHECK: ret i32 0 +} + +; icmp eq with undef simplifies to undef +define i1 @test8() { + %t = icmp eq i32 undef, -1 + ret i1 %t +; CHECK: @test8 +; CHECK: ret i1 undef +} + +; Make sure we don't conclude that relational comparisons simplify to undef +define i1 @test9() { + %t = icmp ugt i32 undef, -1 + ret i1 %t +; CHECK: @test9 +; CHECK: icmp ugt +} + +; Make sure we handle extractvalue +define i64 @test10() { +entry: + %e = extractvalue { i64, i64 } undef, 1 + ret i64 %e +; CHECK: @test10 +; CHECK: ret i64 undef +} |