• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -scalarizer -S -o - | FileCheck %s
3
4define i16 @f1() {
5; CHECK-LABEL: @f1(
6; CHECK-NEXT:  entry:
7; CHECK-NEXT:    br label [[FOR_END:%.*]]
8; CHECK:       for.body:
9; CHECK-NEXT:    [[INSERT:%.*]] = insertelement <4 x i16> [[INSERT]], i16 ptrtoint (i16 ()* @f1 to i16), i32 0
10; CHECK-NEXT:    br label [[FOR_COND:%.*]]
11; CHECK:       for.cond:
12; CHECK-NEXT:    br i1 undef, label [[FOR_BODY:%.*]], label [[FOR_END]]
13; CHECK:       for.end:
14; CHECK-NEXT:    [[EXTRACT:%.*]] = phi i16 [ 1, [[ENTRY:%.*]] ], [ undef, [[FOR_COND]] ]
15; CHECK-NEXT:    ret i16 [[EXTRACT]]
16;
17entry:
18  br label %for.end
19
20for.body:
21  %insert = insertelement <4 x i16> %insert, i16 ptrtoint (i16 () * @f1 to i16), i32 0
22  br label %for.cond
23
24for.cond:
25  br i1 undef, label %for.body, label %for.end
26
27for.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
34  ret i16 %extract
35}
36
37define void @f2() {
38; CHECK-LABEL: @f2(
39; CHECK-NEXT:  entry:
40; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
41; CHECK:       for.body:
42; CHECK-NEXT:    br i1 undef, label [[IF_THEN:%.*]], label [[IF_END8:%.*]]
43; CHECK:       if.then:
44; CHECK-NEXT:    br label [[IF_END8]]
45; CHECK:       for.body2:
46; CHECK-NEXT:    br i1 undef, label [[FOR_END:%.*]], label [[FOR_INC:%.*]]
47; CHECK:       for.end:
48; CHECK-NEXT:    br label [[FOR_INC]]
49; CHECK:       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]]
55; CHECK:       if.end8:
56; CHECK-NEXT:    [[E_SROA_3_4_I0:%.*]] = phi i64 [ undef, [[FOR_BODY]] ], [ undef, [[FOR_COND1_FOR_END7_CRIT_EDGE]] ], [ undef, [[IF_THEN]] ]
57; CHECK-NEXT:    [[E_SROA_3_4_I1:%.*]] = phi i64 [ undef, [[FOR_BODY]] ], [ undef, [[FOR_COND1_FOR_END7_CRIT_EDGE]] ], [ undef, [[IF_THEN]] ]
58; CHECK-NEXT:    br label [[FOR_BODY]]
59;
60entry:
61  br label %for.body
62
63for.body:                                         ; preds = %if.end8, %entry
64  br i1 undef, label %if.then, label %if.end8
65
66if.then:                                          ; preds = %for.body
67  br label %if.end8
68
69for.body2:                                        ; preds = %for.inc
70  br i1 undef, label %for.end, label %for.inc
71
72for.end:                                          ; preds = %for.body2
73  br label %for.inc
74
75for.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
79
80for.cond1.for.end7_crit_edge:                     ; preds = %for.inc
81  br label %if.end8
82
83if.end8:                                          ; preds = %for.cond1.for.end7_crit_edge, %if.then, %for.body
84  ; This used to lead to inserted extractelement instructions between the phis
85  ; in %for.inc.
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 ]
89  br label %for.body
90}
91