phi-and-select.ll 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. ; RUN: opt < %s -sroa -S | FileCheck %s
  2. target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n8:16:32:64"
  3. define i32 @test1() {
  4. ; CHECK-LABEL: @test1(
  5. entry:
  6. %a = alloca [2 x i32]
  7. ; CHECK-NOT: alloca
  8. %a0 = getelementptr [2 x i32], [2 x i32]* %a, i64 0, i32 0
  9. %a1 = getelementptr [2 x i32], [2 x i32]* %a, i64 0, i32 1
  10. store i32 0, i32* %a0
  11. store i32 1, i32* %a1
  12. %v0 = load i32, i32* %a0
  13. %v1 = load i32, i32* %a1
  14. ; CHECK-NOT: store
  15. ; CHECK-NOT: load
  16. %cond = icmp sle i32 %v0, %v1
  17. br i1 %cond, label %then, label %exit
  18. then:
  19. br label %exit
  20. exit:
  21. %phi = phi i32* [ %a1, %then ], [ %a0, %entry ]
  22. ; CHECK: phi i32 [ 1, %{{.*}} ], [ 0, %{{.*}} ]
  23. %result = load i32, i32* %phi
  24. ret i32 %result
  25. }
  26. define i32 @test2() {
  27. ; CHECK-LABEL: @test2(
  28. entry:
  29. %a = alloca [2 x i32]
  30. ; CHECK-NOT: alloca
  31. %a0 = getelementptr [2 x i32], [2 x i32]* %a, i64 0, i32 0
  32. %a1 = getelementptr [2 x i32], [2 x i32]* %a, i64 0, i32 1
  33. store i32 0, i32* %a0
  34. store i32 1, i32* %a1
  35. %v0 = load i32, i32* %a0
  36. %v1 = load i32, i32* %a1
  37. ; CHECK-NOT: store
  38. ; CHECK-NOT: load
  39. %cond = icmp sle i32 %v0, %v1
  40. %select = select i1 %cond, i32* %a1, i32* %a0
  41. ; CHECK: select i1 %{{.*}}, i32 1, i32 0
  42. %result = load i32, i32* %select
  43. ret i32 %result
  44. }
  45. define i32 @test3(i32 %x) {
  46. ; CHECK-LABEL: @test3(
  47. entry:
  48. %a = alloca [2 x i32]
  49. ; CHECK-NOT: alloca
  50. ; Note that we build redundant GEPs here to ensure that having different GEPs
  51. ; into the same alloca partation continues to work with PHI speculation. This
  52. ; was the underlying cause of PR13926.
  53. %a0 = getelementptr [2 x i32], [2 x i32]* %a, i64 0, i32 0
  54. %a0b = getelementptr [2 x i32], [2 x i32]* %a, i64 0, i32 0
  55. %a1 = getelementptr [2 x i32], [2 x i32]* %a, i64 0, i32 1
  56. %a1b = getelementptr [2 x i32], [2 x i32]* %a, i64 0, i32 1
  57. store i32 0, i32* %a0
  58. store i32 1, i32* %a1
  59. ; CHECK-NOT: store
  60. switch i32 %x, label %bb0 [ i32 1, label %bb1
  61. i32 2, label %bb2
  62. i32 3, label %bb3
  63. i32 4, label %bb4
  64. i32 5, label %bb5
  65. i32 6, label %bb6
  66. i32 7, label %bb7 ]
  67. bb0:
  68. br label %exit
  69. bb1:
  70. br label %exit
  71. bb2:
  72. br label %exit
  73. bb3:
  74. br label %exit
  75. bb4:
  76. br label %exit
  77. bb5:
  78. br label %exit
  79. bb6:
  80. br label %exit
  81. bb7:
  82. br label %exit
  83. exit:
  84. %phi = phi i32* [ %a1, %bb0 ], [ %a0, %bb1 ], [ %a0, %bb2 ], [ %a1, %bb3 ],
  85. [ %a1b, %bb4 ], [ %a0b, %bb5 ], [ %a0b, %bb6 ], [ %a1b, %bb7 ]
  86. ; CHECK: phi i32 [ 1, %{{.*}} ], [ 0, %{{.*}} ], [ 0, %{{.*}} ], [ 1, %{{.*}} ], [ 1, %{{.*}} ], [ 0, %{{.*}} ], [ 0, %{{.*}} ], [ 1, %{{.*}} ]
  87. %result = load i32, i32* %phi
  88. ret i32 %result
  89. }
  90. define i32 @test4() {
  91. ; CHECK-LABEL: @test4(
  92. entry:
  93. %a = alloca [2 x i32]
  94. ; CHECK-NOT: alloca
  95. %a0 = getelementptr [2 x i32], [2 x i32]* %a, i64 0, i32 0
  96. %a1 = getelementptr [2 x i32], [2 x i32]* %a, i64 0, i32 1
  97. store i32 0, i32* %a0
  98. store i32 1, i32* %a1
  99. %v0 = load i32, i32* %a0
  100. %v1 = load i32, i32* %a1
  101. ; CHECK-NOT: store
  102. ; CHECK-NOT: load
  103. %cond = icmp sle i32 %v0, %v1
  104. %select = select i1 %cond, i32* %a0, i32* %a0
  105. ; CHECK-NOT: select
  106. %result = load i32, i32* %select
  107. ret i32 %result
  108. ; CHECK: ret i32 0
  109. }
  110. define i32 @test5(i32* %b) {
  111. ; CHECK-LABEL: @test5(
  112. entry:
  113. %a = alloca [2 x i32]
  114. ; CHECK-NOT: alloca
  115. %a1 = getelementptr [2 x i32], [2 x i32]* %a, i64 0, i32 1
  116. store i32 1, i32* %a1
  117. ; CHECK-NOT: store
  118. %select = select i1 true, i32* %a1, i32* %b
  119. ; CHECK-NOT: select
  120. %result = load i32, i32* %select
  121. ; CHECK-NOT: load
  122. ret i32 %result
  123. ; CHECK: ret i32 1
  124. }
  125. declare void @f(i32*, i32*)
  126. define i32 @test6(i32* %b) {
  127. ; CHECK-LABEL: @test6(
  128. entry:
  129. %a = alloca [2 x i32]
  130. %c = alloca i32
  131. ; CHECK-NOT: alloca
  132. %a1 = getelementptr [2 x i32], [2 x i32]* %a, i64 0, i32 1
  133. store i32 1, i32* %a1
  134. %select = select i1 true, i32* %a1, i32* %b
  135. %select2 = select i1 false, i32* %a1, i32* %b
  136. %select3 = select i1 false, i32* %c, i32* %b
  137. ; CHECK: %[[select2:.*]] = select i1 false, i32* undef, i32* %b
  138. ; CHECK: %[[select3:.*]] = select i1 false, i32* undef, i32* %b
  139. ; Note, this would potentially escape the alloca pointer except for the
  140. ; constant folding of the select.
  141. call void @f(i32* %select2, i32* %select3)
  142. ; CHECK: call void @f(i32* %[[select2]], i32* %[[select3]])
  143. %result = load i32, i32* %select
  144. ; CHECK-NOT: load
  145. %dead = load i32, i32* %c
  146. ret i32 %result
  147. ; CHECK: ret i32 1
  148. }
  149. define i32 @test7() {
  150. ; CHECK-LABEL: @test7(
  151. ; CHECK-NOT: alloca
  152. entry:
  153. %X = alloca i32
  154. br i1 undef, label %good, label %bad
  155. good:
  156. %Y1 = getelementptr i32, i32* %X, i64 0
  157. store i32 0, i32* %Y1
  158. br label %exit
  159. bad:
  160. %Y2 = getelementptr i32, i32* %X, i64 1
  161. store i32 0, i32* %Y2
  162. br label %exit
  163. exit:
  164. %P = phi i32* [ %Y1, %good ], [ %Y2, %bad ]
  165. ; CHECK: %[[phi:.*]] = phi i32 [ 0, %good ],
  166. %Z2 = load i32, i32* %P
  167. ret i32 %Z2
  168. ; CHECK: ret i32 %[[phi]]
  169. }
  170. define i32 @test8(i32 %b, i32* %ptr) {
  171. ; Ensure that we rewrite allocas to the used type when that use is hidden by
  172. ; a PHI that can be speculated.
  173. ; CHECK-LABEL: @test8(
  174. ; CHECK-NOT: alloca
  175. ; CHECK-NOT: load
  176. ; CHECK: %[[value:.*]] = load i32, i32* %ptr
  177. ; CHECK-NOT: load
  178. ; CHECK: %[[result:.*]] = phi i32 [ undef, %else ], [ %[[value]], %then ]
  179. ; CHECK-NEXT: ret i32 %[[result]]
  180. entry:
  181. %f = alloca float
  182. %test = icmp ne i32 %b, 0
  183. br i1 %test, label %then, label %else
  184. then:
  185. br label %exit
  186. else:
  187. %bitcast = bitcast float* %f to i32*
  188. br label %exit
  189. exit:
  190. %phi = phi i32* [ %bitcast, %else ], [ %ptr, %then ]
  191. %loaded = load i32, i32* %phi, align 4
  192. ret i32 %loaded
  193. }
  194. define i32 @test9(i32 %b, i32* %ptr) {
  195. ; Same as @test8 but for a select rather than a PHI node.
  196. ; CHECK-LABEL: @test9(
  197. ; CHECK-NOT: alloca
  198. ; CHECK-NOT: load
  199. ; CHECK: %[[value:.*]] = load i32, i32* %ptr
  200. ; CHECK-NOT: load
  201. ; CHECK: %[[result:.*]] = select i1 %{{.*}}, i32 undef, i32 %[[value]]
  202. ; CHECK-NEXT: ret i32 %[[result]]
  203. entry:
  204. %f = alloca float
  205. store i32 0, i32* %ptr
  206. %test = icmp ne i32 %b, 0
  207. %bitcast = bitcast float* %f to i32*
  208. %select = select i1 %test, i32* %bitcast, i32* %ptr
  209. %loaded = load i32, i32* %select, align 4
  210. ret i32 %loaded
  211. }
  212. define float @test10(i32 %b, float* %ptr) {
  213. ; Don't try to promote allocas which are not elligible for it even after
  214. ; rewriting due to the necessity of inserting bitcasts when speculating a PHI
  215. ; node.
  216. ; CHECK-LABEL: @test10(
  217. ; CHECK: %[[alloca:.*]] = alloca
  218. ; CHECK: %[[argvalue:.*]] = load float, float* %ptr
  219. ; CHECK: %[[cast:.*]] = bitcast double* %[[alloca]] to float*
  220. ; CHECK: %[[allocavalue:.*]] = load float, float* %[[cast]]
  221. ; CHECK: %[[result:.*]] = phi float [ %[[allocavalue]], %else ], [ %[[argvalue]], %then ]
  222. ; CHECK-NEXT: ret float %[[result]]
  223. entry:
  224. %f = alloca double
  225. store double 0.0, double* %f
  226. %test = icmp ne i32 %b, 0
  227. br i1 %test, label %then, label %else
  228. then:
  229. br label %exit
  230. else:
  231. %bitcast = bitcast double* %f to float*
  232. br label %exit
  233. exit:
  234. %phi = phi float* [ %bitcast, %else ], [ %ptr, %then ]
  235. %loaded = load float, float* %phi, align 4
  236. ret float %loaded
  237. }
  238. define float @test11(i32 %b, float* %ptr) {
  239. ; Same as @test10 but for a select rather than a PHI node.
  240. ; CHECK-LABEL: @test11(
  241. ; CHECK: %[[alloca:.*]] = alloca
  242. ; CHECK: %[[cast:.*]] = bitcast double* %[[alloca]] to float*
  243. ; CHECK: %[[allocavalue:.*]] = load float, float* %[[cast]]
  244. ; CHECK: %[[argvalue:.*]] = load float, float* %ptr
  245. ; CHECK: %[[result:.*]] = select i1 %{{.*}}, float %[[allocavalue]], float %[[argvalue]]
  246. ; CHECK-NEXT: ret float %[[result]]
  247. entry:
  248. %f = alloca double
  249. store double 0.0, double* %f
  250. store float 0.0, float* %ptr
  251. %test = icmp ne i32 %b, 0
  252. %bitcast = bitcast double* %f to float*
  253. %select = select i1 %test, float* %bitcast, float* %ptr
  254. %loaded = load float, float* %select, align 4
  255. ret float %loaded
  256. }
  257. define i32 @test12(i32 %x, i32* %p) {
  258. ; Ensure we don't crash or fail to nuke dead selects of allocas if no load is
  259. ; never found.
  260. ; CHECK-LABEL: @test12(
  261. ; CHECK-NOT: alloca
  262. ; CHECK-NOT: select
  263. ; CHECK: ret i32 %x
  264. entry:
  265. %a = alloca i32
  266. store i32 %x, i32* %a
  267. %dead = select i1 undef, i32* %a, i32* %p
  268. %load = load i32, i32* %a
  269. ret i32 %load
  270. }
  271. define i32 @test13(i32 %x, i32* %p) {
  272. ; Ensure we don't crash or fail to nuke dead phis of allocas if no load is ever
  273. ; found.
  274. ; CHECK-LABEL: @test13(
  275. ; CHECK-NOT: alloca
  276. ; CHECK-NOT: phi
  277. ; CHECK: ret i32 %x
  278. entry:
  279. %a = alloca i32
  280. store i32 %x, i32* %a
  281. br label %loop
  282. loop:
  283. %phi = phi i32* [ %p, %entry ], [ %a, %loop ]
  284. br i1 undef, label %loop, label %exit
  285. exit:
  286. %load = load i32, i32* %a
  287. ret i32 %load
  288. }
  289. define i32 @test14(i1 %b1, i1 %b2, i32* %ptr) {
  290. ; Check for problems when there are both selects and phis and one is
  291. ; speculatable toward promotion but the other is not. That should block all of
  292. ; the speculation.
  293. ; CHECK-LABEL: @test14(
  294. ; CHECK: alloca
  295. ; CHECK: alloca
  296. ; CHECK: select
  297. ; CHECK: phi
  298. ; CHECK: phi
  299. ; CHECK: select
  300. ; CHECK: ret i32
  301. entry:
  302. %f = alloca i32
  303. %g = alloca i32
  304. store i32 0, i32* %f
  305. store i32 0, i32* %g
  306. %f.select = select i1 %b1, i32* %f, i32* %ptr
  307. br i1 %b2, label %then, label %else
  308. then:
  309. br label %exit
  310. else:
  311. br label %exit
  312. exit:
  313. %f.phi = phi i32* [ %f, %then ], [ %f.select, %else ]
  314. %g.phi = phi i32* [ %g, %then ], [ %ptr, %else ]
  315. %f.loaded = load i32, i32* %f.phi
  316. %g.select = select i1 %b1, i32* %g, i32* %g.phi
  317. %g.loaded = load i32, i32* %g.select
  318. %result = add i32 %f.loaded, %g.loaded
  319. ret i32 %result
  320. }
  321. define i32 @PR13905() {
  322. ; Check a pattern where we have a chain of dead phi nodes to ensure they are
  323. ; deleted and promotion can proceed.
  324. ; CHECK-LABEL: @PR13905(
  325. ; CHECK-NOT: alloca i32
  326. ; CHECK: ret i32 undef
  327. entry:
  328. %h = alloca i32
  329. store i32 0, i32* %h
  330. br i1 undef, label %loop1, label %exit
  331. loop1:
  332. %phi1 = phi i32* [ null, %entry ], [ %h, %loop1 ], [ %h, %loop2 ]
  333. br i1 undef, label %loop1, label %loop2
  334. loop2:
  335. br i1 undef, label %loop1, label %exit
  336. exit:
  337. %phi2 = phi i32* [ %phi1, %loop2 ], [ null, %entry ]
  338. ret i32 undef
  339. }
  340. define i32 @PR13906() {
  341. ; Another pattern which can lead to crashes due to failing to clear out dead
  342. ; PHI nodes or select nodes. This triggers subtly differently from the above
  343. ; cases because the PHI node is (recursively) alive, but the select is dead.
  344. ; CHECK-LABEL: @PR13906(
  345. ; CHECK-NOT: alloca
  346. entry:
  347. %c = alloca i32
  348. store i32 0, i32* %c
  349. br label %for.cond
  350. for.cond:
  351. %d.0 = phi i32* [ undef, %entry ], [ %c, %if.then ], [ %d.0, %for.cond ]
  352. br i1 undef, label %if.then, label %for.cond
  353. if.then:
  354. %tmpcast.d.0 = select i1 undef, i32* %c, i32* %d.0
  355. br label %for.cond
  356. }
  357. define i64 @PR14132(i1 %flag) {
  358. ; CHECK-LABEL: @PR14132(
  359. ; Here we form a PHI-node by promoting the pointer alloca first, and then in
  360. ; order to promote the other two allocas, we speculate the load of the
  361. ; now-phi-node-pointer. In doing so we end up loading a 64-bit value from an i8
  362. ; alloca. While this is a bit dubious, we were asserting on trying to
  363. ; rewrite it. The trick is that the code using the value may carefully take
  364. ; steps to only use the not-undef bits, and so we need to at least loosely
  365. ; support this..
  366. entry:
  367. %a = alloca i64, align 8
  368. %b = alloca i8, align 8
  369. %ptr = alloca i64*, align 8
  370. ; CHECK-NOT: alloca
  371. %ptr.cast = bitcast i64** %ptr to i8**
  372. store i64 0, i64* %a, align 8
  373. store i8 1, i8* %b, align 8
  374. store i64* %a, i64** %ptr, align 8
  375. br i1 %flag, label %if.then, label %if.end
  376. if.then:
  377. store i8* %b, i8** %ptr.cast, align 8
  378. br label %if.end
  379. ; CHECK-NOT: store
  380. ; CHECK: %[[ext:.*]] = zext i8 1 to i64
  381. if.end:
  382. %tmp = load i64*, i64** %ptr, align 8
  383. %result = load i64, i64* %tmp, align 8
  384. ; CHECK-NOT: load
  385. ; CHECK: %[[result:.*]] = phi i64 [ %[[ext]], %if.then ], [ 0, %entry ]
  386. ret i64 %result
  387. ; CHECK-NEXT: ret i64 %[[result]]
  388. }
  389. define float @PR16687(i64 %x, i1 %flag) {
  390. ; CHECK-LABEL: @PR16687(
  391. ; Check that even when we try to speculate the same phi twice (in two slices)
  392. ; on an otherwise promotable construct, we don't get ahead of ourselves and try
  393. ; to promote one of the slices prior to speculating it.
  394. entry:
  395. %a = alloca i64, align 8
  396. store i64 %x, i64* %a
  397. br i1 %flag, label %then, label %else
  398. ; CHECK-NOT: alloca
  399. ; CHECK-NOT: store
  400. ; CHECK: %[[lo:.*]] = trunc i64 %x to i32
  401. ; CHECK: %[[shift:.*]] = lshr i64 %x, 32
  402. ; CHECK: %[[hi:.*]] = trunc i64 %[[shift]] to i32
  403. then:
  404. %a.f = bitcast i64* %a to float*
  405. br label %end
  406. ; CHECK: %[[lo_cast:.*]] = bitcast i32 %[[lo]] to float
  407. else:
  408. %a.raw = bitcast i64* %a to i8*
  409. %a.raw.4 = getelementptr i8, i8* %a.raw, i64 4
  410. %a.raw.4.f = bitcast i8* %a.raw.4 to float*
  411. br label %end
  412. ; CHECK: %[[hi_cast:.*]] = bitcast i32 %[[hi]] to float
  413. end:
  414. %a.phi.f = phi float* [ %a.f, %then ], [ %a.raw.4.f, %else ]
  415. %f = load float, float* %a.phi.f
  416. ret float %f
  417. ; CHECK: %[[phi:.*]] = phi float [ %[[lo_cast]], %then ], [ %[[hi_cast]], %else ]
  418. ; CHECK-NOT: load
  419. ; CHECK: ret float %[[phi]]
  420. }
  421. ; Verifies we fixed PR20425. We should be able to promote all alloca's to
  422. ; registers in this test.
  423. ;
  424. ; %0 = slice
  425. ; %1 = slice
  426. ; %2 = phi(%0, %1) // == slice
  427. define float @simplify_phi_nodes_that_equal_slice(i1 %cond, float* %temp) {
  428. ; CHECK-LABEL: @simplify_phi_nodes_that_equal_slice(
  429. entry:
  430. %arr = alloca [4 x float], align 4
  431. ; CHECK-NOT: alloca
  432. br i1 %cond, label %then, label %else
  433. then:
  434. %0 = getelementptr inbounds [4 x float], [4 x float]* %arr, i64 0, i64 3
  435. store float 1.000000e+00, float* %0, align 4
  436. br label %merge
  437. else:
  438. %1 = getelementptr inbounds [4 x float], [4 x float]* %arr, i64 0, i64 3
  439. store float 2.000000e+00, float* %1, align 4
  440. br label %merge
  441. merge:
  442. %2 = phi float* [ %0, %then ], [ %1, %else ]
  443. store float 0.000000e+00, float* %temp, align 4
  444. %3 = load float, float* %2, align 4
  445. ret float %3
  446. }
  447. ; A slightly complicated example for PR20425.
  448. ;
  449. ; %0 = slice
  450. ; %1 = phi(%0) // == slice
  451. ; %2 = slice
  452. ; %3 = phi(%1, %2) // == slice
  453. define float @simplify_phi_nodes_that_equal_slice_2(i1 %cond, float* %temp) {
  454. ; CHECK-LABEL: @simplify_phi_nodes_that_equal_slice_2(
  455. entry:
  456. %arr = alloca [4 x float], align 4
  457. ; CHECK-NOT: alloca
  458. br i1 %cond, label %then, label %else
  459. then:
  460. %0 = getelementptr inbounds [4 x float], [4 x float]* %arr, i64 0, i64 3
  461. store float 1.000000e+00, float* %0, align 4
  462. br label %then2
  463. then2:
  464. %1 = phi float* [ %0, %then ]
  465. store float 2.000000e+00, float* %1, align 4
  466. br label %merge
  467. else:
  468. %2 = getelementptr inbounds [4 x float], [4 x float]* %arr, i64 0, i64 3
  469. store float 3.000000e+00, float* %2, align 4
  470. br label %merge
  471. merge:
  472. %3 = phi float* [ %1, %then2 ], [ %2, %else ]
  473. store float 0.000000e+00, float* %temp, align 4
  474. %4 = load float, float* %3, align 4
  475. ret float %4
  476. }
  477. %struct.S = type { i32 }
  478. ; Verifies we fixed PR20822. We have a foldable PHI feeding a speculatable PHI
  479. ; which requires the rewriting of the speculated PHI to handle insertion
  480. ; when the incoming pointer is itself from a PHI node. We would previously
  481. ; insert a bitcast instruction *before* a PHI, producing an invalid module;
  482. ; make sure we insert *after* the first non-PHI instruction.
  483. define void @PR20822() {
  484. ; CHECK-LABEL: @PR20822(
  485. entry:
  486. %f = alloca %struct.S, align 4
  487. ; CHECK: %[[alloca:.*]] = alloca
  488. br i1 undef, label %if.end, label %for.cond
  489. for.cond: ; preds = %for.cond, %entry
  490. br label %if.end
  491. if.end: ; preds = %for.cond, %entry
  492. %f2 = phi %struct.S* [ %f, %entry ], [ %f, %for.cond ]
  493. ; CHECK: phi i32
  494. ; CHECK: %[[cast:.*]] = bitcast i32* %[[alloca]] to %struct.S*
  495. phi i32 [ undef, %entry ], [ undef, %for.cond ]
  496. br i1 undef, label %if.then5, label %if.then2
  497. if.then2: ; preds = %if.end
  498. br label %if.then5
  499. if.then5: ; preds = %if.then2, %if.end
  500. %f1 = phi %struct.S* [ undef, %if.then2 ], [ %f2, %if.end ]
  501. ; CHECK: phi {{.*}} %[[cast]]
  502. store %struct.S undef, %struct.S* %f1, align 4
  503. ret void
  504. }