| Chris Lattner | c7a962d | 2009-10-22 00:17:26 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -instcombine -S |
| Chris Lattner | 4ad5eba | 2009-12-19 07:01:15 +0000 | [diff] [blame] | 2 | target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128:n8:16:32" |
| Chris Lattner | 4e3e930 | 2009-08-31 04:36:22 +0000 | [diff] [blame] | 3 | target triple = "i386-apple-darwin10.0" |
| 4 | |
| Chris Lattner | 0cdbc7a | 2009-09-08 00:13:52 +0000 | [diff] [blame] | 5 | define i32 @test0(i8 %tmp2) ssp { |
| Chris Lattner | 4e3e930 | 2009-08-31 04:36:22 +0000 | [diff] [blame] | 6 | entry: |
| 7 | %tmp3 = zext i8 %tmp2 to i32 |
| 8 | %tmp8 = lshr i32 %tmp3, 6 |
| 9 | %tmp9 = lshr i32 %tmp3, 7 |
| 10 | %tmp10 = xor i32 %tmp9, 67108858 |
| 11 | %tmp11 = xor i32 %tmp10, %tmp8 |
| 12 | %tmp12 = xor i32 %tmp11, 0 |
| 13 | ret i32 %tmp12 |
| 14 | } |
| Chris Lattner | 0cdbc7a | 2009-09-08 00:13:52 +0000 | [diff] [blame] | 15 | |
| 16 | ; PR4905 |
| 17 | define <2 x i64> @test1(<2 x i64> %x, <2 x i64> %y) nounwind { |
| 18 | entry: |
| 19 | %conv.i94 = bitcast <2 x i64> %y to <4 x i32> ; <<4 x i32>> [#uses=1] |
| 20 | %sub.i97 = sub <4 x i32> %conv.i94, undef ; <<4 x i32>> [#uses=1] |
| 21 | %conv3.i98 = bitcast <4 x i32> %sub.i97 to <2 x i64> ; <<2 x i64>> [#uses=2] |
| 22 | %conv2.i86 = bitcast <2 x i64> %conv3.i98 to <4 x i32> ; <<4 x i32>> [#uses=1] |
| 23 | %cmp.i87 = icmp sgt <4 x i32> undef, %conv2.i86 ; <<4 x i1>> [#uses=1] |
| 24 | %sext.i88 = sext <4 x i1> %cmp.i87 to <4 x i32> ; <<4 x i32>> [#uses=1] |
| 25 | %conv3.i89 = bitcast <4 x i32> %sext.i88 to <2 x i64> ; <<2 x i64>> [#uses=1] |
| 26 | %and.i = and <2 x i64> %conv3.i89, %conv3.i98 ; <<2 x i64>> [#uses=1] |
| 27 | %or.i = or <2 x i64> zeroinitializer, %and.i ; <<2 x i64>> [#uses=1] |
| 28 | %conv2.i43 = bitcast <2 x i64> %or.i to <4 x i32> ; <<4 x i32>> [#uses=1] |
| 29 | %sub.i = sub <4 x i32> zeroinitializer, %conv2.i43 ; <<4 x i32>> [#uses=1] |
| 30 | %conv3.i44 = bitcast <4 x i32> %sub.i to <2 x i64> ; <<2 x i64>> [#uses=1] |
| 31 | ret <2 x i64> %conv3.i44 |
| 32 | } |
| 33 | |
| Chris Lattner | d3210e1 | 2009-09-08 03:44:51 +0000 | [diff] [blame] | 34 | |
| 35 | ; PR4908 |
| 36 | define void @test2(<1 x i16>* nocapture %b, i32* nocapture %c) nounwind ssp { |
| 37 | entry: |
| 38 | %arrayidx = getelementptr inbounds <1 x i16>* %b, i64 undef ; <<1 x i16>*> |
| 39 | %tmp2 = load <1 x i16>* %arrayidx ; <<1 x i16>> [#uses=1] |
| 40 | %tmp6 = bitcast <1 x i16> %tmp2 to i16 ; <i16> [#uses=1] |
| 41 | %tmp7 = zext i16 %tmp6 to i32 ; <i32> [#uses=1] |
| 42 | %ins = or i32 0, %tmp7 ; <i32> [#uses=1] |
| 43 | %arrayidx20 = getelementptr inbounds i32* %c, i64 undef ; <i32*> [#uses=1] |
| 44 | store i32 %ins, i32* %arrayidx20 |
| 45 | ret void |
| 46 | } |
| Torok Edwin | 1539a35 | 2009-10-21 10:49:00 +0000 | [diff] [blame] | 47 | |
| 48 | ; PR5262 |
| 49 | @tmp2 = global i64 0 ; <i64*> [#uses=1] |
| 50 | |
| 51 | declare void @use(i64) nounwind |
| 52 | |
| 53 | define void @foo(i1) nounwind align 2 { |
| 54 | ; <label>:1 |
| 55 | br i1 %0, label %2, label %3 |
| 56 | |
| 57 | ; <label>:2 ; preds = %1 |
| 58 | br label %3 |
| 59 | |
| 60 | ; <label>:3 ; preds = %2, %1 |
| 61 | %4 = phi i8 [ 1, %2 ], [ 0, %1 ] ; <i8> [#uses=1] |
| 62 | %5 = icmp eq i8 %4, 0 ; <i1> [#uses=1] |
| 63 | %6 = load i64* @tmp2, align 8 ; <i64> [#uses=1] |
| 64 | %7 = select i1 %5, i64 0, i64 %6 ; <i64> [#uses=1] |
| 65 | br label %8 |
| 66 | |
| 67 | ; <label>:8 ; preds = %3 |
| 68 | call void @use(i64 %7) |
| 69 | ret void |
| 70 | } |
| 71 | |
| 72 | %t0 = type { i32, i32 } |
| 73 | %t1 = type { i32, i32, i32, i32, i32* } |
| 74 | |
| 75 | declare %t0* @bar2(i64) |
| 76 | |
| 77 | define void @bar3(i1, i1) nounwind align 2 { |
| 78 | ; <label>:2 |
| 79 | br i1 %1, label %10, label %3 |
| 80 | |
| 81 | ; <label>:3 ; preds = %2 |
| 82 | %4 = getelementptr inbounds %t0* null, i64 0, i32 1 ; <i32*> [#uses=0] |
| 83 | %5 = getelementptr inbounds %t1* null, i64 0, i32 4 ; <i32**> [#uses=1] |
| 84 | %6 = load i32** %5, align 8 ; <i32*> [#uses=1] |
| 85 | %7 = icmp ne i32* %6, null ; <i1> [#uses=1] |
| 86 | %8 = zext i1 %7 to i32 ; <i32> [#uses=1] |
| 87 | %9 = add i32 %8, 0 ; <i32> [#uses=1] |
| 88 | br label %10 |
| 89 | |
| 90 | ; <label>:10 ; preds = %3, %2 |
| 91 | %11 = phi i32 [ %9, %3 ], [ 0, %2 ] ; <i32> [#uses=1] |
| 92 | br i1 %1, label %12, label %13 |
| 93 | |
| 94 | ; <label>:12 ; preds = %10 |
| 95 | br label %13 |
| 96 | |
| 97 | ; <label>:13 ; preds = %12, %10 |
| 98 | %14 = zext i32 %11 to i64 ; <i64> [#uses=1] |
| 99 | %15 = tail call %t0* @bar2(i64 %14) nounwind ; <%0*> [#uses=0] |
| 100 | ret void |
| 101 | } |
| Chris Lattner | c7a962d | 2009-10-22 00:17:26 +0000 | [diff] [blame] | 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | ; PR5262 |
| 107 | ; Make sure the PHI node gets put in a place where all of its operands dominate |
| 108 | ; it. |
| 109 | define i64 @test4(i1 %c, i64* %P) nounwind align 2 { |
| 110 | BB0: |
| 111 | br i1 %c, label %BB1, label %BB2 |
| 112 | |
| 113 | BB1: |
| 114 | br label %BB2 |
| 115 | |
| 116 | BB2: |
| 117 | %v5_ = phi i1 [ true, %BB0], [false, %BB1] |
| 118 | %v6 = load i64* %P |
| 119 | br label %l8 |
| 120 | |
| 121 | l8: |
| 122 | br label %l10 |
| 123 | |
| 124 | l10: |
| 125 | %v11 = select i1 %v5_, i64 0, i64 %v6 |
| 126 | ret i64 %v11 |
| 127 | } |
| Chris Lattner | a73ecf0 | 2009-11-26 22:04:42 +0000 | [diff] [blame] | 128 | |
| 129 | ; PR5471 |
| 130 | define arm_apcscc i32 @test5a() { |
| 131 | ret i32 0 |
| 132 | } |
| 133 | |
| 134 | define arm_apcscc void @test5() { |
| 135 | store i1 true, i1* undef |
| 136 | %1 = invoke i32 @test5a() to label %exit unwind label %exit |
| 137 | exit: |
| 138 | ret void |
| 139 | } |
| Chris Lattner | 77c36d6 | 2009-12-03 01:05:45 +0000 | [diff] [blame] | 140 | |
| 141 | |
| 142 | ; PR5673 |
| 143 | |
| 144 | @test6g = external global i32* |
| 145 | |
| 146 | define arm_aapcs_vfpcc i32 @test6(i32 %argc, i8** %argv) nounwind { |
| 147 | entry: |
| 148 | store i32* getelementptr (i32* bitcast (i32 (i32, i8**)* @test6 to i32*), i32 -2048), i32** @test6g, align 4 |
| 149 | unreachable |
| 150 | } |
| Chris Lattner | 4ad5eba | 2009-12-19 07:01:15 +0000 | [diff] [blame] | 151 | |
| 152 | |
| 153 | ; PR5827 |
| 154 | |
| 155 | %class.RuleBasedBreakIterator = type { i64 ()* } |
| 156 | %class.UStack = type { i8** } |
| 157 | |
| 158 | define i32 @_ZN22RuleBasedBreakIterator15checkDictionaryEi(%class.RuleBasedBreakIterator* %this, i32 %x) align 2 { |
| 159 | entry: |
| 160 | %breaks = alloca %class.UStack, align 4 ; <%class.UStack*> [#uses=3] |
| 161 | call void @_ZN6UStackC1Ei(%class.UStack* %breaks, i32 0) |
| 162 | %tobool = icmp ne i32 %x, 0 ; <i1> [#uses=1] |
| 163 | br i1 %tobool, label %cond.end, label %cond.false |
| 164 | |
| 165 | terminate.handler: ; preds = %ehcleanup |
| 166 | %exc = call i8* @llvm.eh.exception() ; <i8*> [#uses=1] |
| 167 | %0 = call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %exc, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i32 1) ; <i32> [#uses=0] |
| 168 | call void @_ZSt9terminatev() noreturn nounwind |
| 169 | unreachable |
| 170 | |
| 171 | ehcleanup: ; preds = %cond.false |
| 172 | %exc1 = call i8* @llvm.eh.exception() ; <i8*> [#uses=2] |
| 173 | %1 = call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %exc1, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* null) ; <i32> [#uses=0] |
| 174 | invoke void @_ZN6UStackD1Ev(%class.UStack* %breaks) |
| 175 | to label %cont unwind label %terminate.handler |
| 176 | |
| 177 | cont: ; preds = %ehcleanup |
| 178 | call void @_Unwind_Resume_or_Rethrow(i8* %exc1) |
| 179 | unreachable |
| 180 | |
| 181 | cond.false: ; preds = %entry |
| 182 | %tmp4 = getelementptr inbounds %class.RuleBasedBreakIterator* %this, i32 0, i32 0 ; <i64 ()**> [#uses=1] |
| 183 | %tmp5 = load i64 ()** %tmp4 ; <i64 ()*> [#uses=1] |
| 184 | %call = invoke i64 %tmp5() |
| 185 | to label %cond.end unwind label %ehcleanup ; <i64> [#uses=1] |
| 186 | |
| 187 | cond.end: ; preds = %cond.false, %entry |
| 188 | %cond = phi i64 [ 0, %entry ], [ %call, %cond.false ] ; <i64> [#uses=1] |
| 189 | %conv = trunc i64 %cond to i32 ; <i32> [#uses=1] |
| 190 | call void @_ZN6UStackD1Ev(%class.UStack* %breaks) |
| 191 | ret i32 %conv |
| 192 | } |
| 193 | |
| 194 | declare void @_ZN6UStackC1Ei(%class.UStack*, i32) |
| 195 | |
| 196 | declare void @_ZN6UStackD1Ev(%class.UStack*) |
| 197 | |
| 198 | declare i32 @__gxx_personality_v0(...) |
| 199 | |
| 200 | declare i8* @llvm.eh.exception() nounwind readonly |
| 201 | |
| 202 | declare i32 @llvm.eh.selector(i8*, i8*, ...) nounwind |
| 203 | |
| 204 | declare void @_ZSt9terminatev() |
| 205 | |
| 206 | declare void @_Unwind_Resume_or_Rethrow(i8*) |
| Chris Lattner | 2cecedf | 2010-02-01 18:04:58 +0000 | [diff] [blame] | 207 | |
| 208 | |
| 209 | |
| 210 | ; rdar://7590304 |
| 211 | define i8* @test10(i8* %self, i8* %tmp3) { |
| 212 | entry: |
| 213 | store i1 true, i1* undef |
| 214 | store i1 true, i1* undef |
| 215 | invoke arm_apcscc void @test10a() |
| 216 | to label %invoke.cont unwind label %try.handler ; <i8*> [#uses=0] |
| 217 | |
| 218 | invoke.cont: ; preds = %entry |
| 219 | unreachable |
| 220 | |
| 221 | try.handler: ; preds = %entry |
| 222 | ret i8* %self |
| 223 | } |
| 224 | |
| 225 | define void @test10a() { |
| 226 | ret void |
| 227 | } |
| 228 | |
| Chris Lattner | 9b6a178 | 2010-02-09 01:12:41 +0000 | [diff] [blame] | 229 | |
| 230 | ; PR6193 |
| 231 | define i32 @test11(i32 %aMaskWidth, i8 %aStride) nounwind { |
| 232 | entry: |
| 233 | %conv41 = sext i8 %aStride to i32 |
| 234 | %neg = xor i32 %conv41, -1 |
| 235 | %and42 = and i32 %aMaskWidth, %neg |
| 236 | %and47 = and i32 130, %conv41 |
| 237 | %or = or i32 %and42, %and47 |
| 238 | ret i32 %or |
| 239 | } |