1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes='function(scalarizer)' -S -o - | FileCheck %s
7 ; CHECK-NEXT: br label [[FOR_END:%.*]]
9 ; CHECK-NEXT: [[INSERT:%.*]] = insertelement <4 x i16> [[INSERT]], i16 ptrtoint (ptr @f1 to i16), i32 0
10 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
12 ; CHECK-NEXT: br i1 undef, label [[FOR_BODY:%.*]], label [[FOR_END]]
14 ; CHECK-NEXT: [[PHI_I0:%.*]] = phi i16 [ 1, [[ENTRY:%.*]] ], [ poison, [[FOR_COND]] ]
15 ; CHECK-NEXT: ret i16 [[PHI_I0]]
21 %insert = insertelement <4 x i16> %insert, i16 ptrtoint (ptr @f1 to i16), i32 0
25 br i1 undef, label %for.body, label %for.end
28 ; opt used to hang when scalarizing this code. When scattering %insert we
29 ; need to analyze the insertelement in the unreachable-from-entry block
30 ; for.body. Note that the insertelement instruction depends on itself, and
31 ; this kind of IR is not allowed in reachable-from-entry blocks.
32 %phi = phi <4 x i16> [ <i16 1, i16 1, i16 1, i16 1>, %entry ], [ %insert, %for.cond ]
33 %extract = extractelement <4 x i16> %phi, i32 0
40 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
42 ; CHECK-NEXT: br i1 undef, label [[IF_THEN:%.*]], label [[IF_END8:%.*]]
44 ; CHECK-NEXT: br label [[IF_END8]]
46 ; CHECK-NEXT: br i1 undef, label [[FOR_END:%.*]], label [[FOR_INC:%.*]]
48 ; CHECK-NEXT: br label [[FOR_INC]]
50 ; CHECK-NEXT: [[E_SROA_3_2:%.*]] = phi <2 x i64> [ <i64 1, i64 1>, [[FOR_END]] ], [ [[E_SROA_3_2]], [[FOR_BODY2:%.*]] ]
51 ; CHECK-NEXT: [[TMP0:%.*]] = phi i32 [ 6, [[FOR_END]] ], [ [[TMP0]], [[FOR_BODY2]] ]
52 ; CHECK-NEXT: br i1 undef, label [[FOR_BODY2]], label [[FOR_COND1_FOR_END7_CRIT_EDGE:%.*]]
53 ; CHECK: for.cond1.for.end7_crit_edge:
54 ; CHECK-NEXT: br label [[IF_END8]]
56 ; CHECK-NEXT: [[E_SROA_3_4_I0:%.*]] = phi i64 [ undef, [[FOR_BODY]] ], [ poison, [[FOR_COND1_FOR_END7_CRIT_EDGE]] ], [ undef, [[IF_THEN]] ]
57 ; CHECK-NEXT: [[E_SROA_3_4_I1:%.*]] = phi i64 [ undef, [[FOR_BODY]] ], [ poison, [[FOR_COND1_FOR_END7_CRIT_EDGE]] ], [ undef, [[IF_THEN]] ]
58 ; CHECK-NEXT: br label [[FOR_BODY]]
63 for.body: ; preds = %if.end8, %entry
64 br i1 undef, label %if.then, label %if.end8
66 if.then: ; preds = %for.body
69 for.body2: ; preds = %for.inc
70 br i1 undef, label %for.end, label %for.inc
72 for.end: ; preds = %for.body2
75 for.inc: ; preds = %for.end, %for.body2
76 %e.sroa.3.2 = phi <2 x i64> [ <i64 1, i64 1>, %for.end ], [ %e.sroa.3.2, %for.body2 ]
77 %0 = phi i32 [ 6, %for.end ], [ %0, %for.body2 ]
78 br i1 undef, label %for.body2, label %for.cond1.for.end7_crit_edge
80 for.cond1.for.end7_crit_edge: ; preds = %for.inc
83 if.end8: ; preds = %for.cond1.for.end7_crit_edge, %if.then, %for.body
84 ; This used to lead to inserted extractelement instructions between the phis
86 ; %e.sroa.3.2 is defined in a block that is unreachable from entry so we can
87 ; safely replace it with undef in the phi defining e.sroa.3.4.
88 %e.sroa.3.4 = phi <2 x i64> [ undef, %for.body ], [ %e.sroa.3.2, %for.cond1.for.end7_crit_edge ], [ undef, %if.then ]