393 lines · plain
1; RUN: opt < %s -passes=instcombine -S2target 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"3target triple = "i386-apple-darwin10.0"4 5define i32 @test0(i8 %tmp2) ssp {6entry:7 %tmp3 = zext i8 %tmp2 to i328 %tmp8 = lshr i32 %tmp3, 6 9 %tmp9 = lshr i32 %tmp3, 7 10 %tmp10 = xor i32 %tmp9, 6710885811 %tmp11 = xor i32 %tmp10, %tmp8 12 %tmp12 = xor i32 %tmp11, 0 13 ret i32 %tmp1214}15 16; PR490517define <2 x i64> @test1(<2 x i64> %x, <2 x i64> %y) nounwind {18entry: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, poison ; <<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> poison, %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.i4432}33 34 35; PR490836define void @test2(ptr nocapture %b, ptr nocapture %c) nounwind ssp {37entry:38 %arrayidx = getelementptr inbounds <1 x i16>, ptr %b, i64 0 ; <ptr>39 %tmp2 = load <1 x i16>, ptr %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, ptr %c, i64 0 ; <ptr> [#uses=1]44 store i32 %ins, ptr %arrayidx2045 ret void46}47 48; PR526249@tmp2 = global i64 0 ; <ptr> [#uses=1]50 51declare void @use(i64) nounwind52 53define void @foo(i1) nounwind align 2 {54; <label>:155 br i1 %0, label %2, label %356 57; <label>:2 ; preds = %158 br label %359 60; <label>:3 ; preds = %2, %161 %4 = phi i8 [ 1, %2 ], [ 0, %1 ] ; <i8> [#uses=1]62 %5 = icmp eq i8 %4, 0 ; <i1> [#uses=1]63 %6 = load i64, ptr @tmp2, align 8 ; <i64> [#uses=1]64 %7 = select i1 %5, i64 0, i64 %6 ; <i64> [#uses=1]65 br label %866 67; <label>:8 ; preds = %368 call void @use(i64 %7)69 ret void70}71 72%t0 = type { i32, i32 }73%t1 = type { i32, i32, i32, i32, ptr }74 75declare ptr @bar2(i64)76 77define void @bar3(i1, i1) nounwind align 2 {78; <label>:279 br i1 %1, label %10, label %380 81; <label>:3 ; preds = %282 %4 = getelementptr inbounds %t0, ptr null, i64 0, i32 1 ; <ptr> [#uses=0]83 %5 = getelementptr inbounds %t1, ptr null, i64 0, i32 4 ; <ptr> [#uses=1]84 %6 = load ptr, ptr %5, align 8 ; <ptr> [#uses=1]85 %7 = icmp ne ptr %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 %1089 90; <label>:10 ; preds = %3, %291 %11 = phi i32 [ %9, %3 ], [ 0, %2 ] ; <i32> [#uses=1]92 br i1 %1, label %12, label %1393 94; <label>:12 ; preds = %1095 br label %1396 97; <label>:13 ; preds = %12, %1098 %14 = zext i32 %11 to i64 ; <i64> [#uses=1]99 %15 = tail call ptr @bar2(i64 %14) nounwind ; <ptr> [#uses=0]100 ret void101}102 103 104 105 106; PR5262107; Make sure the PHI node gets put in a place where all of its operands dominate108; it.109define i64 @test4(i1 %c, ptr %P) nounwind align 2 {110BB0:111 br i1 %c, label %BB1, label %BB2112 113BB1:114 br label %BB2115 116BB2:117 %v5_ = phi i1 [ true, %BB0], [false, %BB1]118 %v6 = load i64, ptr %P119 br label %l8120 121l8:122 br label %l10123 124l10:125 %v11 = select i1 %v5_, i64 0, i64 %v6126 ret i64 %v11127}128 129; PR5471130define i32 @test5a() {131 ret i32 0132}133 134define void @test5(ptr %ptr) personality ptr @__gxx_personality_v0 {135 store i1 true, ptr %ptr136 %r = invoke i32 @test5a() to label %exit unwind label %unwind137unwind:138 %exn = landingpad {ptr, i32}139 cleanup140 br label %exit141exit:142 ret void143}144 145 146; PR5673147 148@test6g = external global ptr 149 150define arm_aapcs_vfpcc i32 @test6(i32 %argc, ptr %argv) nounwind {151entry:152 store ptr getelementptr (i32, ptr @test6, i32 -2048), ptr @test6g, align 4153 unreachable154}155 156 157; PR5827158 159%class.RuleBasedBreakIterator = type { ptr }160%class.UStack = type { ptr }161 162define i32 @_ZN22RuleBasedBreakIterator15checkDictionaryEi(ptr %this, i32 %x) align 2 personality ptr @__gxx_personality_v0 {163entry:164 %breaks = alloca %class.UStack, align 4 ; <ptr> [#uses=3]165 call void @_ZN6UStackC1Ei(ptr %breaks, i32 0)166 %tobool = icmp ne i32 %x, 0 ; <i1> [#uses=1]167 br i1 %tobool, label %cond.end, label %cond.false168 169terminate.handler: ; preds = %ehcleanup170 %exc = landingpad { ptr, i32 }171 cleanup172 call void @_ZSt9terminatev() noreturn nounwind173 unreachable174 175ehcleanup: ; preds = %cond.false176 %exc1 = landingpad { ptr, i32 }177 catch ptr null178 invoke void @_ZN6UStackD1Ev(ptr %breaks)179 to label %cont unwind label %terminate.handler180 181cont: ; preds = %ehcleanup182 resume { ptr, i32 } %exc1183 184cond.false: ; preds = %entry185 %tmp4 = getelementptr inbounds %class.RuleBasedBreakIterator, ptr %this, i32 0, i32 0 ; <ptr> [#uses=1]186 %tmp5 = load ptr, ptr %tmp4 ; <ptr> [#uses=1]187 %call = invoke i64 %tmp5()188 to label %cond.end unwind label %ehcleanup ; <i64> [#uses=1]189 190cond.end: ; preds = %cond.false, %entry191 %cond = phi i64 [ 0, %entry ], [ %call, %cond.false ] ; <i64> [#uses=1]192 %conv = trunc i64 %cond to i32 ; <i32> [#uses=1]193 call void @_ZN6UStackD1Ev(ptr %breaks)194 ret i32 %conv195}196 197declare void @_ZN6UStackC1Ei(ptr, i32)198 199declare void @_ZN6UStackD1Ev(ptr)200 201declare i32 @__gxx_personality_v0(...)202 203declare void @_ZSt9terminatev()204 205declare void @_Unwind_Resume_or_Rethrow(ptr)206 207 208 209; rdar://7590304210define ptr @test10(ptr %self, ptr %tmp3, ptr %ptr1, ptr %ptr2) personality ptr @__gxx_personality_v0 {211entry:212 store i1 true, ptr %ptr1213 store i1 true, ptr %ptr2214 invoke void @test10a()215 to label %invoke.cont unwind label %try.handler ; <ptr> [#uses=0]216 217invoke.cont: ; preds = %entry218 unreachable219 220try.handler: ; preds = %entry221 %exn = landingpad {ptr, i32}222 catch ptr null223 ret ptr %self224}225 226define void @test10a() {227 ret void228}229 230 231; PR6193232define i32 @test11(i32 %aMaskWidth, i8 %aStride) nounwind {233entry:234 %conv41 = sext i8 %aStride to i32235 %neg = xor i32 %conv41, -1236 %and42 = and i32 %aMaskWidth, %neg237 %and47 = and i32 130, %conv41238 %or = or i32 %and42, %and47239 ret i32 %or240}241 242; PR6503243define void @test12(ptr %A) nounwind {244entry:245 %tmp1 = load i32, ptr %A246 %cmp = icmp ugt i32 1, %tmp1 ; <i1> [#uses=1]247 %conv = zext i1 %cmp to i32 ; <i32> [#uses=1]248 %tmp2 = load i32, ptr %A249 %cmp3 = icmp ne i32 %tmp2, 0 ; <i1> [#uses=1]250 %conv4 = zext i1 %cmp3 to i32 ; <i32> [#uses=1]251 %or = or i32 %conv, %conv4 ; <i32> [#uses=1]252 %cmp5 = icmp ugt i32 0, %or ; <i1> [#uses=1]253 %conv6 = zext i1 %cmp5 to i32 ; <i32> [#uses=0]254 ret void255}256 257%s1 = type { %s2, %s2, [6 x %s2], i32, i32, i32, [1 x i32], [0 x i8] }258%s2 = type { i64 }259define void @test13(ptr %ptr1, ptr %ptr2, ptr %ptr3) nounwind {260entry:261 %0 = getelementptr inbounds %s1, ptr null, i64 0, i32 2, i64 0, i32 0262 %1 = getelementptr inbounds %s1, ptr null, i64 0, i32 2, i64 1, i32 0263 %.pre = load i32, ptr %0, align 8264 %2 = lshr i32 %.pre, 19265 %brmerge = or i1 1, 0266 %3 = and i32 %2, 3267 %4 = add nsw i32 %3, 1268 %5 = shl i32 %4, 19269 %6 = add i32 %5, 1572864270 %7 = and i32 %6, 1572864271 %8 = load i64, ptr %1, align 8272 %trunc156 = trunc i64 %8 to i32273 %9 = and i32 %trunc156, -1537274 %10 = and i32 %9, -6145275 %11 = or i32 %10, 2048276 %12 = and i32 %11, -24577277 %13 = or i32 %12, 16384278 %14 = or i32 %13, 98304279 store i32 %14, ptr %ptr1, align 8280 %15 = and i32 %14, -1572865281 %16 = or i32 %15, %7282 store i32 %16, ptr %ptr2, align 8283 %17 = and i32 %16, -449284 %18 = or i32 %17, 64285 store i32 %18, ptr %ptr3, align 8286 unreachable287}288 289 290; PR8807291declare i32 @test14f(ptr) nounwind292 293define void @test14(ptr %ptr) nounwind readnone {294entry:295 %call10 = call i32 @test14f(ptr byval(i32) %ptr)296 ret void297}298 299 300; PR8896301@g_54 = external global [7 x i16]302 303define void @test15(ptr %p_92, i1 %c1) nounwind {304entry:305%0 = load i32, ptr %p_92, align 4306%1 = icmp ne i32 %0, 0307%2 = zext i1 %1 to i32308%3 = call i32 @func_14() nounwind309%4 = trunc i32 %3 to i16310%5 = sext i16 %4 to i32311%6 = trunc i32 %5 to i16312br i1 %c1, label %"3", label %"5"313 314"3": ; preds = %entry315%7 = sext i16 %6 to i32316%8 = ashr i32 %7, -1649554541317%9 = trunc i32 %8 to i16318br label %"5"319 320"5": ; preds = %"3", %entry321%10 = phi i16 [ %9, %"3" ], [ %6, %entry ]322%11 = sext i16 %10 to i32323%12 = xor i32 %2, %11324%13 = sext i32 %12 to i64325%14 = icmp ne i64 %13, 0326br i1 %14, label %return, label %"7"327 328"7": ; preds = %"5"329ret void330 331return: ; preds = %"5"332ret void333}334 335declare i32 @func_14()336 337 338define double @test16(i32 %a) nounwind {339 %cmp = icmp slt i32 %a, 2340 %select = select i1 %cmp, double 2.000000e+00, double 3.141592e+00341 ret double %select342}343 344 345; PR8983346%struct.basic_ios = type { i8 }347 348define ptr@test17() ssp {349entry:350 ret ptr null351}352 353; PR9013354define void @test18() nounwind ssp {355entry:356 br label %for.cond357 358for.cond: ; preds = %for.inc, %entry359 %l_197.0 = phi i32 [ 0, %entry ], [ %sub.i, %for.inc ]360 br label %for.inc361 362for.inc: ; preds = %for.cond363 %conv = and i32 %l_197.0, 255364 %sub.i = add nsw i32 %conv, -1365 br label %for.cond366 367return: ; No predecessors!368 ret void369}370 371; PR11275372declare void @test18b() noreturn373declare void @test18foo(ptr)374declare void @test18a() noreturn375define fastcc void @test18x(ptr %t0, i1 %b) uwtable align 2 personality ptr @__gxx_personality_v0 {376entry:377 br i1 %b, label %e1, label %e2378e1:379 invoke void @test18b() noreturn380 to label %u unwind label %lpad381e2:382 invoke void @test18a() noreturn383 to label %u unwind label %lpad384lpad:385 %t5 = phi ptr [ %t0, %e1 ], [ %t0, %e2 ]386 %lpad.nonloopexit262 = landingpad { ptr, i32 }387 cleanup388 call void @test18foo(ptr %t5)389 unreachable390u:391 unreachable392}393