1 ; RUN: opt -sccp -S < %s | FileCheck %s
5 define double @test1() {
6 %t = sitofp i32 undef to double
9 ; CHECK: ret double 0.0
14 ; Check that lots of stuff doesn't get turned into undef.
15 define i32 @test2() nounwind readnone ssp {
16 ; CHECK-LABEL: @test2(
18 br label %control.outer.outer
20 control.outer.loopexit.us-lcssa: ; preds = %control
21 br label %control.outer.loopexit
23 control.outer.loopexit: ; preds = %control.outer.loopexit.us-lcssa.us, %control.outer.loopexit.us-lcssa
24 br label %control.outer.outer.backedge
26 control.outer.outer: ; preds = %control.outer.outer.backedge, %init
27 %switchCond.0.ph.ph = phi i32 [ 2, %init ], [ 3, %control.outer.outer.backedge ] ; <i32> [#uses=2]
28 %i.0.ph.ph = phi i32 [ undef, %init ], [ %i.0.ph.ph.be, %control.outer.outer.backedge ] ; <i32> [#uses=1]
29 %tmp4 = icmp eq i32 %i.0.ph.ph, 0 ; <i1> [#uses=1]
30 br i1 %tmp4, label %control.outer.outer.split.us, label %control.outer.outer.control.outer.outer.split_crit_edge
32 control.outer.outer.control.outer.outer.split_crit_edge: ; preds = %control.outer.outer
33 br label %control.outer
35 control.outer.outer.split.us: ; preds = %control.outer.outer
36 br label %control.outer.us
38 control.outer.us: ; preds = %bb3.us, %control.outer.outer.split.us
39 %A.0.ph.us = phi i32 [ %switchCond.0.us, %bb3.us ], [ 4, %control.outer.outer.split.us ] ; <i32> [#uses=2]
40 %switchCond.0.ph.us = phi i32 [ %A.0.ph.us, %bb3.us ], [ %switchCond.0.ph.ph, %control.outer.outer.split.us ] ; <i32> [#uses=1]
43 bb3.us: ; preds = %control.us
44 br label %control.outer.us
46 bb0.us: ; preds = %control.us
49 ; CHECK: control.us: ; preds = %bb0.us, %control.outer.us
50 ; CHECK-NEXT: %switchCond.0.us = phi i32
51 ; CHECK-NEXT: switch i32 %switchCond.0.us
52 control.us: ; preds = %bb0.us, %control.outer.us
53 %switchCond.0.us = phi i32 [ %A.0.ph.us, %bb0.us ], [ %switchCond.0.ph.us, %control.outer.us ] ; <i32> [#uses=2]
54 switch i32 %switchCond.0.us, label %control.outer.loopexit.us-lcssa.us [
56 i32 1, label %bb1.us-lcssa.us
58 i32 4, label %bb4.us-lcssa.us
61 control.outer.loopexit.us-lcssa.us: ; preds = %control.us
62 br label %control.outer.loopexit
64 bb1.us-lcssa.us: ; preds = %control.us
67 bb4.us-lcssa.us: ; preds = %control.us
70 control.outer: ; preds = %bb3, %control.outer.outer.control.outer.outer.split_crit_edge
71 %A.0.ph = phi i32 [ %nextId17, %bb3 ], [ 4, %control.outer.outer.control.outer.outer.split_crit_edge ] ; <i32> [#uses=1]
72 %switchCond.0.ph = phi i32 [ 0, %bb3 ], [ %switchCond.0.ph.ph, %control.outer.outer.control.outer.outer.split_crit_edge ] ; <i32> [#uses=1]
75 control: ; preds = %bb0, %control.outer
76 %switchCond.0 = phi i32 [ %A.0.ph, %bb0 ], [ %switchCond.0.ph, %control.outer ] ; <i32> [#uses=2]
77 switch i32 %switchCond.0, label %control.outer.loopexit.us-lcssa [
79 i32 1, label %bb1.us-lcssa
81 i32 4, label %bb4.us-lcssa
84 bb4.us-lcssa: ; preds = %control
87 bb4: ; preds = %bb4.us-lcssa, %bb4.us-lcssa.us
88 br label %control.outer.outer.backedge
90 control.outer.outer.backedge: ; preds = %bb4, %control.outer.loopexit
91 %i.0.ph.ph.be = phi i32 [ 1, %bb4 ], [ 0, %control.outer.loopexit ] ; <i32> [#uses=1]
92 br label %control.outer.outer
94 bb3: ; preds = %control
95 %nextId17 = add i32 %switchCond.0, -2 ; <i32> [#uses=1]
96 br label %control.outer
98 bb0: ; preds = %control
101 bb1.us-lcssa: ; preds = %control
104 bb1: ; preds = %bb1.us-lcssa, %bb1.us-lcssa.us
108 ; Make sure SCCP honors the xor "idiom"
110 define i32 @test3() {
111 %t = xor i32 undef, undef
113 ; CHECK-LABEL: @test3(
117 ; Be conservative with FP ops
118 define double @test4(double %x) {
119 %t = fadd double %x, undef
121 ; CHECK-LABEL: @test4(
122 ; CHECK: fadd double %x, undef
125 ; Make sure casts produce a possible value
126 define i32 @test5() {
127 %t = sext i8 undef to i32
129 ; CHECK-LABEL: @test5(
133 ; Make sure ashr produces a possible value
134 define i32 @test6() {
135 %t = ashr i32 undef, 31
137 ; CHECK-LABEL: @test6(
141 ; Make sure lshr produces a possible value
142 define i32 @test7() {
143 %t = lshr i32 undef, 31
145 ; CHECK-LABEL: @test7(
149 ; icmp eq with undef simplifies to undef
151 %t = icmp eq i32 undef, -1
153 ; CHECK-LABEL: @test8(
154 ; CHECK: ret i1 undef
157 ; Make sure we don't conclude that relational comparisons simplify to undef
159 %t = icmp ugt i32 undef, -1
161 ; CHECK-LABEL: @test9(
165 ; Make sure we handle extractvalue
166 define i64 @test10() {
168 %e = extractvalue { i64, i64 } undef, 1
170 ; CHECK-LABEL: @test10(
171 ; CHECK: ret i64 undef
174 @GV = external global i32
176 define i32 @test11(i1 %tobool) {
178 %shr4 = ashr i32 undef, zext (i1 icmp eq (i32* bitcast (i32 (i1)* @test11 to i32*), i32* @GV) to i32)
180 ; CHECK-LABEL: @test11(
185 define double @test12(double %x) {
186 %t = fneg double undef
188 ; CHECK-LABEL: @test12(
189 ; CHECK: double undef