[EarlyCSE] DSE of atomic unordered stores
[oota-llvm.git] / test / Transforms / SCCP / undef-resolve.ll
index bed561c8e4f24dd039657a4ed81f3332ecc1c7cf..2b40183c2cc58bad16417a4aefac4f076b91a8a7 100644 (file)
@@ -1,11 +1,11 @@
-; RUN: opt %s -sccp -S | FileCheck %s
+; RUN: opt -sccp -S < %s | FileCheck %s
 
 
 ; PR6940
 define double @test1() {
   %t = sitofp i32 undef to double
   ret double %t
-; CHECK: @test1
+; CHECK-LABEL: @test1(
 ; CHECK: ret double 0.0
 }
 
@@ -13,7 +13,7 @@ define double @test1() {
 ; rdar://7832370
 ; Check that lots of stuff doesn't get turned into undef.
 define i32 @test2() nounwind readnone ssp {
-; CHECK: @test2
+; CHECK-LABEL: @test2(
 init:
   br label %control.outer.outer
 
@@ -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-LABEL: @test3(
+; CHECK: ret i32 0
+}
+
+; Be conservative with FP ops
+define double @test4(double %x) {
+  %t = fadd double %x, undef
+  ret double %t
+; CHECK-LABEL: @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-LABEL: @test5(
+; CHECK: ret i32 0
+}
+
+; Make sure ashr produces a possible value
+define i32 @test6() {
+  %t = ashr i32 undef, 31
+  ret i32 %t
+; CHECK-LABEL: @test6(
+; CHECK: ret i32 -1
+}
+
+; Make sure lshr produces a possible value
+define i32 @test7() {
+  %t = lshr i32 undef, 31
+  ret i32 %t
+; CHECK-LABEL: @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-LABEL: @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-LABEL: @test9(
+; CHECK: icmp ugt
+}
+
+; Make sure we handle extractvalue
+define i64 @test10() { 
+entry:
+  %e = extractvalue { i64, i64 } undef, 1
+  ret i64 %e
+; CHECK-LABEL: @test10(
+; CHECK: ret i64 undef
+}