crash.ll 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. ; RUN: opt < %s -instcombine -S
  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"
  3. target triple = "i386-apple-darwin10.0"
  4. define i32 @test0(i8 %tmp2) ssp {
  5. entry:
  6. %tmp3 = zext i8 %tmp2 to i32
  7. %tmp8 = lshr i32 %tmp3, 6
  8. %tmp9 = lshr i32 %tmp3, 7
  9. %tmp10 = xor i32 %tmp9, 67108858
  10. %tmp11 = xor i32 %tmp10, %tmp8
  11. %tmp12 = xor i32 %tmp11, 0
  12. ret i32 %tmp12
  13. }
  14. ; PR4905
  15. define <2 x i64> @test1(<2 x i64> %x, <2 x i64> %y) nounwind {
  16. entry:
  17. %conv.i94 = bitcast <2 x i64> %y to <4 x i32> ; <<4 x i32>> [#uses=1]
  18. %sub.i97 = sub <4 x i32> %conv.i94, undef ; <<4 x i32>> [#uses=1]
  19. %conv3.i98 = bitcast <4 x i32> %sub.i97 to <2 x i64> ; <<2 x i64>> [#uses=2]
  20. %conv2.i86 = bitcast <2 x i64> %conv3.i98 to <4 x i32> ; <<4 x i32>> [#uses=1]
  21. %cmp.i87 = icmp sgt <4 x i32> undef, %conv2.i86 ; <<4 x i1>> [#uses=1]
  22. %sext.i88 = sext <4 x i1> %cmp.i87 to <4 x i32> ; <<4 x i32>> [#uses=1]
  23. %conv3.i89 = bitcast <4 x i32> %sext.i88 to <2 x i64> ; <<2 x i64>> [#uses=1]
  24. %and.i = and <2 x i64> %conv3.i89, %conv3.i98 ; <<2 x i64>> [#uses=1]
  25. %or.i = or <2 x i64> zeroinitializer, %and.i ; <<2 x i64>> [#uses=1]
  26. %conv2.i43 = bitcast <2 x i64> %or.i to <4 x i32> ; <<4 x i32>> [#uses=1]
  27. %sub.i = sub <4 x i32> zeroinitializer, %conv2.i43 ; <<4 x i32>> [#uses=1]
  28. %conv3.i44 = bitcast <4 x i32> %sub.i to <2 x i64> ; <<2 x i64>> [#uses=1]
  29. ret <2 x i64> %conv3.i44
  30. }
  31. ; PR4908
  32. define void @test2(<1 x i16>* nocapture %b, i32* nocapture %c) nounwind ssp {
  33. entry:
  34. %arrayidx = getelementptr inbounds <1 x i16>, <1 x i16>* %b, i64 undef ; <<1 x i16>*>
  35. %tmp2 = load <1 x i16>, <1 x i16>* %arrayidx ; <<1 x i16>> [#uses=1]
  36. %tmp6 = bitcast <1 x i16> %tmp2 to i16 ; <i16> [#uses=1]
  37. %tmp7 = zext i16 %tmp6 to i32 ; <i32> [#uses=1]
  38. %ins = or i32 0, %tmp7 ; <i32> [#uses=1]
  39. %arrayidx20 = getelementptr inbounds i32, i32* %c, i64 undef ; <i32*> [#uses=1]
  40. store i32 %ins, i32* %arrayidx20
  41. ret void
  42. }
  43. ; PR5262
  44. @tmp2 = global i64 0 ; <i64*> [#uses=1]
  45. declare void @use(i64) nounwind
  46. define void @foo(i1) nounwind align 2 {
  47. ; <label>:1
  48. br i1 %0, label %2, label %3
  49. ; <label>:2 ; preds = %1
  50. br label %3
  51. ; <label>:3 ; preds = %2, %1
  52. %4 = phi i8 [ 1, %2 ], [ 0, %1 ] ; <i8> [#uses=1]
  53. %5 = icmp eq i8 %4, 0 ; <i1> [#uses=1]
  54. %6 = load i64, i64* @tmp2, align 8 ; <i64> [#uses=1]
  55. %7 = select i1 %5, i64 0, i64 %6 ; <i64> [#uses=1]
  56. br label %8
  57. ; <label>:8 ; preds = %3
  58. call void @use(i64 %7)
  59. ret void
  60. }
  61. %t0 = type { i32, i32 }
  62. %t1 = type { i32, i32, i32, i32, i32* }
  63. declare %t0* @bar2(i64)
  64. define void @bar3(i1, i1) nounwind align 2 {
  65. ; <label>:2
  66. br i1 %1, label %10, label %3
  67. ; <label>:3 ; preds = %2
  68. %4 = getelementptr inbounds %t0, %t0* null, i64 0, i32 1 ; <i32*> [#uses=0]
  69. %5 = getelementptr inbounds %t1, %t1* null, i64 0, i32 4 ; <i32**> [#uses=1]
  70. %6 = load i32*, i32** %5, align 8 ; <i32*> [#uses=1]
  71. %7 = icmp ne i32* %6, null ; <i1> [#uses=1]
  72. %8 = zext i1 %7 to i32 ; <i32> [#uses=1]
  73. %9 = add i32 %8, 0 ; <i32> [#uses=1]
  74. br label %10
  75. ; <label>:10 ; preds = %3, %2
  76. %11 = phi i32 [ %9, %3 ], [ 0, %2 ] ; <i32> [#uses=1]
  77. br i1 %1, label %12, label %13
  78. ; <label>:12 ; preds = %10
  79. br label %13
  80. ; <label>:13 ; preds = %12, %10
  81. %14 = zext i32 %11 to i64 ; <i64> [#uses=1]
  82. %15 = tail call %t0* @bar2(i64 %14) nounwind ; <%0*> [#uses=0]
  83. ret void
  84. }
  85. ; PR5262
  86. ; Make sure the PHI node gets put in a place where all of its operands dominate
  87. ; it.
  88. define i64 @test4(i1 %c, i64* %P) nounwind align 2 {
  89. BB0:
  90. br i1 %c, label %BB1, label %BB2
  91. BB1:
  92. br label %BB2
  93. BB2:
  94. %v5_ = phi i1 [ true, %BB0], [false, %BB1]
  95. %v6 = load i64, i64* %P
  96. br label %l8
  97. l8:
  98. br label %l10
  99. l10:
  100. %v11 = select i1 %v5_, i64 0, i64 %v6
  101. ret i64 %v11
  102. }
  103. ; PR5471
  104. define i32 @test5a() {
  105. ret i32 0
  106. }
  107. define void @test5() personality i32 (...)* @__gxx_personality_v0 {
  108. store i1 true, i1* undef
  109. %r = invoke i32 @test5a() to label %exit unwind label %unwind
  110. unwind:
  111. %exn = landingpad {i8*, i32}
  112. cleanup
  113. br label %exit
  114. exit:
  115. ret void
  116. }
  117. ; PR5673
  118. @test6g = external global i32*
  119. define arm_aapcs_vfpcc i32 @test6(i32 %argc, i8** %argv) nounwind {
  120. entry:
  121. store i32* getelementptr (i32, i32* bitcast (i32 (i32, i8**)* @test6 to i32*), i32 -2048), i32** @test6g, align 4
  122. unreachable
  123. }
  124. ; PR5827
  125. %class.RuleBasedBreakIterator = type { i64 ()* }
  126. %class.UStack = type { i8** }
  127. define i32 @_ZN22RuleBasedBreakIterator15checkDictionaryEi(%class.RuleBasedBreakIterator* %this, i32 %x) align 2 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
  128. entry:
  129. %breaks = alloca %class.UStack, align 4 ; <%class.UStack*> [#uses=3]
  130. call void @_ZN6UStackC1Ei(%class.UStack* %breaks, i32 0)
  131. %tobool = icmp ne i32 %x, 0 ; <i1> [#uses=1]
  132. br i1 %tobool, label %cond.end, label %cond.false
  133. terminate.handler: ; preds = %ehcleanup
  134. %exc = landingpad { i8*, i32 }
  135. cleanup
  136. call void @_ZSt9terminatev() noreturn nounwind
  137. unreachable
  138. ehcleanup: ; preds = %cond.false
  139. %exc1 = landingpad { i8*, i32 }
  140. catch i8* null
  141. invoke void @_ZN6UStackD1Ev(%class.UStack* %breaks)
  142. to label %cont unwind label %terminate.handler
  143. cont: ; preds = %ehcleanup
  144. resume { i8*, i32 } %exc1
  145. cond.false: ; preds = %entry
  146. %tmp4 = getelementptr inbounds %class.RuleBasedBreakIterator, %class.RuleBasedBreakIterator* %this, i32 0, i32 0 ; <i64 ()**> [#uses=1]
  147. %tmp5 = load i64 ()*, i64 ()** %tmp4 ; <i64 ()*> [#uses=1]
  148. %call = invoke i64 %tmp5()
  149. to label %cond.end unwind label %ehcleanup ; <i64> [#uses=1]
  150. cond.end: ; preds = %cond.false, %entry
  151. %cond = phi i64 [ 0, %entry ], [ %call, %cond.false ] ; <i64> [#uses=1]
  152. %conv = trunc i64 %cond to i32 ; <i32> [#uses=1]
  153. call void @_ZN6UStackD1Ev(%class.UStack* %breaks)
  154. ret i32 %conv
  155. }
  156. declare void @_ZN6UStackC1Ei(%class.UStack*, i32)
  157. declare void @_ZN6UStackD1Ev(%class.UStack*)
  158. declare i32 @__gxx_personality_v0(...)
  159. declare void @_ZSt9terminatev()
  160. declare void @_Unwind_Resume_or_Rethrow(i8*)
  161. ; rdar://7590304
  162. define i8* @test10(i8* %self, i8* %tmp3) personality i32 (...)* @__gxx_personality_v0 {
  163. entry:
  164. store i1 true, i1* undef
  165. store i1 true, i1* undef
  166. invoke void @test10a()
  167. to label %invoke.cont unwind label %try.handler ; <i8*> [#uses=0]
  168. invoke.cont: ; preds = %entry
  169. unreachable
  170. try.handler: ; preds = %entry
  171. %exn = landingpad {i8*, i32}
  172. catch i8* null
  173. ret i8* %self
  174. }
  175. define void @test10a() {
  176. ret void
  177. }
  178. ; PR6193
  179. define i32 @test11(i32 %aMaskWidth, i8 %aStride) nounwind {
  180. entry:
  181. %conv41 = sext i8 %aStride to i32
  182. %neg = xor i32 %conv41, -1
  183. %and42 = and i32 %aMaskWidth, %neg
  184. %and47 = and i32 130, %conv41
  185. %or = or i32 %and42, %and47
  186. ret i32 %or
  187. }
  188. ; PR6503
  189. define void @test12(i32* %A) nounwind {
  190. entry:
  191. %tmp1 = load i32, i32* %A
  192. %cmp = icmp ugt i32 1, %tmp1 ; <i1> [#uses=1]
  193. %conv = zext i1 %cmp to i32 ; <i32> [#uses=1]
  194. %tmp2 = load i32, i32* %A
  195. %cmp3 = icmp ne i32 %tmp2, 0 ; <i1> [#uses=1]
  196. %conv4 = zext i1 %cmp3 to i32 ; <i32> [#uses=1]
  197. %or = or i32 %conv, %conv4 ; <i32> [#uses=1]
  198. %cmp5 = icmp ugt i32 undef, %or ; <i1> [#uses=1]
  199. %conv6 = zext i1 %cmp5 to i32 ; <i32> [#uses=0]
  200. ret void
  201. }
  202. %s1 = type { %s2, %s2, [6 x %s2], i32, i32, i32, [1 x i32], [0 x i8] }
  203. %s2 = type { i64 }
  204. define void @test13() nounwind ssp {
  205. entry:
  206. %0 = getelementptr inbounds %s1, %s1* null, i64 0, i32 2, i64 0, i32 0
  207. %1 = bitcast i64* %0 to i32*
  208. %2 = getelementptr inbounds %s1, %s1* null, i64 0, i32 2, i64 1, i32 0
  209. %.pre = load i32, i32* %1, align 8
  210. %3 = lshr i32 %.pre, 19
  211. %brmerge = or i1 undef, undef
  212. %4 = and i32 %3, 3
  213. %5 = add nsw i32 %4, 1
  214. %6 = shl i32 %5, 19
  215. %7 = add i32 %6, 1572864
  216. %8 = and i32 %7, 1572864
  217. %9 = load i64, i64* %2, align 8
  218. %trunc156 = trunc i64 %9 to i32
  219. %10 = and i32 %trunc156, -1537
  220. %11 = and i32 %10, -6145
  221. %12 = or i32 %11, 2048
  222. %13 = and i32 %12, -24577
  223. %14 = or i32 %13, 16384
  224. %15 = or i32 %14, 98304
  225. store i32 %15, i32* undef, align 8
  226. %16 = and i32 %15, -1572865
  227. %17 = or i32 %16, %8
  228. store i32 %17, i32* undef, align 8
  229. %18 = and i32 %17, -449
  230. %19 = or i32 %18, 64
  231. store i32 %19, i32* undef, align 8
  232. unreachable
  233. }
  234. ; PR8807
  235. declare i32 @test14f(i8* (i8*)*) nounwind
  236. define void @test14() nounwind readnone {
  237. entry:
  238. %tmp = bitcast i32 (i8* (i8*)*)* @test14f to i32 (i32*)*
  239. %call10 = call i32 %tmp(i32* byval undef)
  240. ret void
  241. }
  242. ; PR8896
  243. @g_54 = external global [7 x i16]
  244. define void @test15(i32* %p_92) nounwind {
  245. entry:
  246. %0 = load i32, i32* %p_92, align 4
  247. %1 = icmp ne i32 %0, 0
  248. %2 = zext i1 %1 to i32
  249. %3 = call i32 @func_14() nounwind
  250. %4 = trunc i32 %3 to i16
  251. %5 = sext i16 %4 to i32
  252. %6 = trunc i32 %5 to i16
  253. br i1 undef, label %"3", label %"5"
  254. "3": ; preds = %entry
  255. %7 = sext i16 %6 to i32
  256. %8 = ashr i32 %7, -1649554541
  257. %9 = trunc i32 %8 to i16
  258. br label %"5"
  259. "5": ; preds = %"3", %entry
  260. %10 = phi i16 [ %9, %"3" ], [ %6, %entry ]
  261. %11 = sext i16 %10 to i32
  262. %12 = xor i32 %2, %11
  263. %13 = sext i32 %12 to i64
  264. %14 = icmp ne i64 %13, 0
  265. br i1 %14, label %return, label %"7"
  266. "7": ; preds = %"5"
  267. ret void
  268. return: ; preds = %"5"
  269. ret void
  270. }
  271. declare i32 @func_14()
  272. define double @test16(i32 %a) nounwind {
  273. %cmp = icmp slt i32 %a, 2
  274. %select = select i1 %cmp, double 2.000000e+00, double 3.141592e+00
  275. ret double %select
  276. }
  277. ; PR8983
  278. %struct.basic_ios = type { i8 }
  279. define %struct.basic_ios *@test17() ssp {
  280. entry:
  281. %add.ptr.i = getelementptr i8, i8* null, i64 undef
  282. %0 = bitcast i8* %add.ptr.i to %struct.basic_ios*
  283. ret %struct.basic_ios* %0
  284. }
  285. ; PR9013
  286. define void @test18() nounwind ssp {
  287. entry:
  288. br label %for.cond
  289. for.cond: ; preds = %for.inc, %entry
  290. %l_197.0 = phi i32 [ 0, %entry ], [ %sub.i, %for.inc ]
  291. br label %for.inc
  292. for.inc: ; preds = %for.cond
  293. %conv = and i32 %l_197.0, 255
  294. %sub.i = add nsw i32 %conv, -1
  295. br label %for.cond
  296. return: ; No predecessors!
  297. ret void
  298. }
  299. ; PR11275
  300. declare void @test18b() noreturn
  301. declare void @test18foo(double**)
  302. declare void @test18a() noreturn
  303. define fastcc void @test18x(i8* %t0, i1 %b) uwtable align 2 personality i32 (...)* @__gxx_personality_v0 {
  304. entry:
  305. br i1 %b, label %e1, label %e2
  306. e1:
  307. %t2 = bitcast i8* %t0 to double**
  308. invoke void @test18b() noreturn
  309. to label %u unwind label %lpad
  310. e2:
  311. %t4 = bitcast i8* %t0 to double**
  312. invoke void @test18a() noreturn
  313. to label %u unwind label %lpad
  314. lpad:
  315. %t5 = phi double** [ %t2, %e1 ], [ %t4, %e2 ]
  316. %lpad.nonloopexit262 = landingpad { i8*, i32 }
  317. cleanup
  318. call void @test18foo(double** %t5)
  319. unreachable
  320. u:
  321. unreachable
  322. }