blob: 2d8e63e313421ec4f525d52ef2dda3928e26007e [file] [log] [blame]
Chris Lattner18fdaba2010-03-05 06:19:13 +00001; RUN: llc -march=x86 %s -o -
2; RUN: llc -march=x86-64 %s -o -
3
4; PR6497
5
6; Chain and flag folding issues.
7define i32 @test1() nounwind ssp {
8entry:
9 %tmp5.i = volatile load i32* undef ; <i32> [#uses=1]
10 %conv.i = zext i32 %tmp5.i to i64 ; <i64> [#uses=1]
11 %tmp12.i = volatile load i32* undef ; <i32> [#uses=1]
12 %conv13.i = zext i32 %tmp12.i to i64 ; <i64> [#uses=1]
13 %shl.i = shl i64 %conv13.i, 32 ; <i64> [#uses=1]
14 %or.i = or i64 %shl.i, %conv.i ; <i64> [#uses=1]
15 %add16.i = add i64 %or.i, 256 ; <i64> [#uses=1]
16 %shr.i = lshr i64 %add16.i, 8 ; <i64> [#uses=1]
17 %conv19.i = trunc i64 %shr.i to i32 ; <i32> [#uses=1]
18 volatile store i32 %conv19.i, i32* undef
19 ret i32 undef
20}
Chris Lattnerf2f64e92010-03-10 23:46:44 +000021
22; PR6533
23define void @test2(i1 %x, i32 %y) nounwind {
24 %land.ext = zext i1 %x to i32 ; <i32> [#uses=1]
25 %and = and i32 %y, 1 ; <i32> [#uses=1]
26 %xor = xor i32 %and, %land.ext ; <i32> [#uses=1]
27 %cmp = icmp eq i32 %xor, 1 ; <i1> [#uses=1]
28 br i1 %cmp, label %if.end, label %if.then
29
30if.then: ; preds = %land.end
31 ret void
32
33if.end: ; preds = %land.end
34 ret void
35}
Chris Lattnerb3e87b22010-03-12 07:15:36 +000036
37; PR6577
38%pair = type { i64, double }
39
Chris Lattnerda0688e2010-03-14 18:44:35 +000040define void @test3() {
Chris Lattnerb3e87b22010-03-12 07:15:36 +000041dependentGraph243.exit:
42 %subject19 = load %pair* undef ; <%1> [#uses=1]
43 %0 = extractvalue %pair %subject19, 1 ; <double> [#uses=2]
44 %1 = select i1 undef, double %0, double undef ; <double> [#uses=1]
45 %2 = select i1 undef, double %1, double %0 ; <double> [#uses=1]
46 %3 = insertvalue %pair undef, double %2, 1 ; <%1> [#uses=1]
47 store %pair %3, %pair* undef
48 ret void
49}
Chris Lattnerda0688e2010-03-14 18:44:35 +000050
51; PR6605
52define i64 @test4(i8* %P) nounwind ssp {
53entry:
54 %tmp1 = load i8* %P ; <i8> [#uses=3]
55 %tobool = icmp eq i8 %tmp1, 0 ; <i1> [#uses=1]
56 %tmp58 = sext i1 %tobool to i8 ; <i8> [#uses=1]
57 %mul.i = and i8 %tmp58, %tmp1 ; <i8> [#uses=1]
58 %conv6 = zext i8 %mul.i to i32 ; <i32> [#uses=1]
59 %cmp = icmp ne i8 %tmp1, 1 ; <i1> [#uses=1]
60 %conv11 = zext i1 %cmp to i32 ; <i32> [#uses=1]
61 %call12 = tail call i32 @safe(i32 %conv11) nounwind ; <i32> [#uses=1]
62 %and = and i32 %conv6, %call12 ; <i32> [#uses=1]
63 %tobool13 = icmp eq i32 %and, 0 ; <i1> [#uses=1]
64 br i1 %tobool13, label %if.else, label %return
65
66if.else: ; preds = %entry
67 br label %return
68
69return: ; preds = %if.else, %entry
70 ret i64 undef
71}
72
73declare i32 @safe(i32)
Chris Lattnerc4a3f232010-03-14 19:46:02 +000074
75; PR6607
76define fastcc void @test5(i32 %FUNC) nounwind {
77foo:
78 %0 = load i8* undef, align 1 ; <i8> [#uses=3]
79 %1 = sext i8 %0 to i32 ; <i32> [#uses=2]
80 %2 = zext i8 %0 to i32 ; <i32> [#uses=1]
81 %tmp1.i5037 = urem i32 %2, 10 ; <i32> [#uses=1]
82 %tmp.i5038 = icmp ugt i32 %tmp1.i5037, 15 ; <i1> [#uses=1]
83 %3 = zext i1 %tmp.i5038 to i8 ; <i8> [#uses=1]
84 %4 = icmp slt i8 %0, %3 ; <i1> [#uses=1]
85 %5 = add nsw i32 %1, 256 ; <i32> [#uses=1]
86 %storemerge.i.i57 = select i1 %4, i32 %5, i32 %1 ; <i32> [#uses=1]
87 %6 = shl i32 %storemerge.i.i57, 16 ; <i32> [#uses=1]
88 %7 = sdiv i32 %6, -256 ; <i32> [#uses=1]
89 %8 = trunc i32 %7 to i8 ; <i8> [#uses=1]
90 store i8 %8, i8* undef, align 1
91 ret void
92}
Chris Lattner0220ba72010-03-15 19:09:43 +000093
94
Chris Lattner24ad3ed2010-04-07 18:03:19 +000095; Crash commoning identical asms.
Chris Lattnerb1ceece2010-04-07 18:04:56 +000096; PR6803
Chris Lattner24ad3ed2010-04-07 18:03:19 +000097define void @test6(i1 %C) nounwind optsize ssp {
98entry:
99 br i1 %C, label %do.body55, label %do.body92
100
101do.body55: ; preds = %if.else36
102 call void asm sideeffect "foo", "~{dirflag},~{fpsr},~{flags}"() nounwind, !srcloc !0
103 ret void
104
105do.body92: ; preds = %if.then66
106 call void asm sideeffect "foo", "~{dirflag},~{fpsr},~{flags}"() nounwind, !srcloc !1
107 ret void
108}
109
110!0 = metadata !{i32 633550}
111!1 = metadata !{i32 634261}
Bill Wendlingb545cde2010-04-20 18:14:47 +0000112
113
114; Crash during XOR optimization.
115; <rdar://problem/7869290>
116
117define void @test7() nounwind ssp {
118entry:
119 br i1 undef, label %bb14, label %bb67
120
121bb14:
122 %tmp0 = trunc i16 undef to i1
123 %tmp1 = load i8* undef, align 8
124 %tmp2 = shl i8 %tmp1, 4
125 %tmp3 = lshr i8 %tmp2, 7
126 %tmp4 = trunc i8 %tmp3 to i1
127 %tmp5 = icmp ne i1 %tmp0, %tmp4
128 br i1 %tmp5, label %bb14, label %bb67
129
130bb67:
131 ret void
132}
Jakob Stoklund Olesenf2e4afd2010-07-07 20:33:27 +0000133
134; Crash when trying to copy AH to AL.
135; PR7540
136define void @copy8bitregs() nounwind {
137entry:
138 %div.i = sdiv i32 115200, 0
139 %shr8.i = lshr i32 %div.i, 8
140 %conv4.i = trunc i32 %shr8.i to i8
141 call void asm sideeffect "outb $0, ${1:w}", "{ax},N{dx},~{dirflag},~{fpsr},~{flags}"(i8 %conv4.i, i32 1017) nounwind
142 unreachable
143}
Chris Lattner9cd3da42011-01-16 02:56:53 +0000144
145; Crash trying to form conditional increment with fp value.
146; PR8981
147define i32 @test9(double %X) ssp align 2 {
148entry:
149 %0 = fcmp one double %X, 0.000000e+00
150 %cond = select i1 %0, i32 1, i32 2
151 ret i32 %cond
152}
153
Chris Lattnerdec28ce2011-01-16 08:48:11 +0000154
155; PR8514 - Crash in match address do to "heroics" turning and-of-shift into
156; shift of and.
157%struct.S0 = type { i8, [2 x i8], i8 }
158
159define void @func_59(i32 %p_63) noreturn nounwind {
160entry:
161 br label %for.body
162
163for.body: ; preds = %for.inc44, %entry
164 %p_63.addr.1 = phi i32 [ %p_63, %entry ], [ 0, %for.inc44 ]
165 %l_74.0 = phi i32 [ 0, %entry ], [ %add46, %for.inc44 ]
166 br i1 undef, label %for.inc44, label %bb.nph81
167
168bb.nph81: ; preds = %for.body
169 %tmp98 = add i32 %p_63.addr.1, 0
170 br label %for.body22
171
172for.body22: ; preds = %for.body22, %bb.nph81
173 %l_75.077 = phi i64 [ %ins, %for.body22 ], [ undef, %bb.nph81 ]
174 %tmp110 = trunc i64 %l_75.077 to i32
175 %tmp111 = and i32 %tmp110, 65535
176 %arrayidx32.0 = getelementptr [9 x [5 x [2 x %struct.S0]]]* undef, i32 0, i32 %l_74.0, i32 %tmp98, i32 %tmp111, i32 0
177 store i8 1, i8* %arrayidx32.0, align 4
178 %tmp106 = shl i32 %tmp110, 2
179 %tmp107 = and i32 %tmp106, 262140
180 %scevgep99.sum114 = or i32 %tmp107, 1
181 %arrayidx32.1.1 = getelementptr [9 x [5 x [2 x %struct.S0]]]* undef, i32 0, i32 %l_74.0, i32 %tmp98, i32 0, i32 1, i32 %scevgep99.sum114
182 store i8 0, i8* %arrayidx32.1.1, align 1
183 %ins = or i64 undef, undef
184 br label %for.body22
185
186for.inc44: ; preds = %for.body
187 %add46 = add i32 %l_74.0, 1
188 br label %for.body
189}
Chris Lattner915eeb42011-02-13 09:10:56 +0000190
191; PR9028
192define void @f(i64 %A) nounwind {
193entry:
194 %0 = zext i64 %A to i160
195 %1 = shl i160 %0, 64
196 %2 = zext i160 %1 to i576
197 %3 = zext i96 undef to i576
198 %4 = or i576 %3, %2
199 store i576 %4, i576* undef, align 8
200 ret void
201}