• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2;RUN: opt -newgvn -S < %s | FileCheck %s
3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4target triple = "x86_64-apple-macosx10.12.0"
5;; Ensure we don't infinite loop when all phi arguments are really unreachable or self-defined
6define void @fn1(i64 %arg) {
7; CHECK-LABEL: @fn1(
8; CHECK-NEXT:  entry:
9; CHECK-NEXT:    br i1 undef, label [[IF_THEN:%.*]], label [[COND_TRUE:%.*]]
10; CHECK:       if.then:
11; CHECK-NEXT:    br i1 false, label [[FIRSTPHIBLOCK:%.*]], label [[TEMP:%.*]]
12; CHECK:       firstphiblock:
13; CHECK-NEXT:    br i1 undef, label %for.cond17thread-pre-split, label [[SECONDPHIBLOCK:%.*]]
14; CHECK:       secondphiblock:
15; CHECK-NEXT:    [[SECONDPHI:%.*]] = phi i64 [ [[THIRDPHI:%.*]], [[THIRDPHIBLOCK:%.*]] ], [ undef, [[FIRSTPHIBLOCK]] ]
16; CHECK-NEXT:    br i1 undef, label [[FIRSTPHIBLOCK]], label [[THIRDPHIBLOCK]]
17; CHECK:       thirdphiblock:
18; CHECK-NEXT:    [[THIRDPHI]] = phi i64 [ [[SECONDPHI]], [[SECONDPHIBLOCK]] ], [ [[DIV:%.*]], [[COND_TRUE]] ]
19; CHECK-NEXT:    br label [[SECONDPHIBLOCK]]
20; CHECK:       for.cond17thread-pre-split:
21; CHECK-NEXT:    br label [[COND_TRUE]]
22; CHECK:       cond.true:
23; CHECK-NEXT:    [[DIV]] = sdiv i64 [[ARG:%.*]], 4
24; CHECK-NEXT:    br label [[THIRDPHIBLOCK]]
25; CHECK:       temp:
26; CHECK-NEXT:    ret void
27;
28entry:
29  br i1 undef, label %if.then, label %cond.true
30if.then:
31  br i1 false, label %firstphiblock, label %temp
32firstphiblock:
33  %firstphi = phi i64 [ %arg, %if.then ], [ undef, %secondphiblock ]
34  br i1 undef, label %for.cond17thread-pre-split, label %secondphiblock
35secondphiblock:
36  %secondphi = phi i64 [ %thirdphi, %thirdphiblock ], [ %firstphi, %firstphiblock ]
37  br i1 undef, label %firstphiblock, label %thirdphiblock
38thirdphiblock:
39  %thirdphi = phi i64 [ %secondphi, %secondphiblock ], [ %div, %cond.true ]
40  br label %secondphiblock
41for.cond17thread-pre-split:
42  br label %cond.true
43cond.true:
44  %fourthphi = phi i64 [ %arg, %entry ], [ %firstphi, %for.cond17thread-pre-split ]
45  %div = sdiv i64 %fourthphi, 4
46  br label %thirdphiblock
47temp:
48  ret void
49}
50define void @fn2(i64 %arg) {
51; CHECK-LABEL: @fn2(
52; CHECK-NEXT:  entry:
53; CHECK-NEXT:    br i1 undef, label [[IF_THEN:%.*]], label [[COND_TRUE:%.*]]
54; CHECK:       if.then:
55; CHECK-NEXT:    br i1 false, label [[FIRSTPHIBLOCK:%.*]], label [[TEMP:%.*]]
56; CHECK:       firstphiblock:
57; CHECK-NEXT:    [[FIRSTPHI:%.*]] = phi i64 [ undef, [[IF_THEN]] ], [ [[SECONDPHI:%.*]], [[SECONDPHIBLOCK:%.*]] ]
58; CHECK-NEXT:    br i1 undef, label %for.cond17thread-pre-split, label [[SECONDPHIBLOCK]]
59; CHECK:       secondphiblock:
60; CHECK-NEXT:    [[SECONDPHI]] = phi i64 [ [[THIRDPHI:%.*]], [[THIRDPHIBLOCK:%.*]] ], [ [[FIRSTPHI]], [[FIRSTPHIBLOCK]] ]
61; CHECK-NEXT:    br i1 undef, label [[FIRSTPHIBLOCK]], label [[THIRDPHIBLOCK]]
62; CHECK:       thirdphiblock:
63; CHECK-NEXT:    [[THIRDPHI]] = phi i64 [ [[SECONDPHI]], [[SECONDPHIBLOCK]] ], [ [[DIV:%.*]], [[COND_TRUE]] ]
64; CHECK-NEXT:    br label [[SECONDPHIBLOCK]]
65; CHECK:       for.cond17thread-pre-split:
66; CHECK-NEXT:    br label [[COND_TRUE]]
67; CHECK:       cond.true:
68; CHECK-NEXT:    [[FOURTHPHI:%.*]] = phi i64 [ [[ARG:%.*]], [[ENTRY:%.*]] ], [ [[FIRSTPHI]], %for.cond17thread-pre-split ]
69; CHECK-NEXT:    [[DIV]] = sdiv i64 [[FOURTHPHI]], 4
70; CHECK-NEXT:    br label [[THIRDPHIBLOCK]]
71; CHECK:       temp:
72; CHECK-NEXT:    ret void
73;
74entry:
75  br i1 undef, label %if.then, label %cond.true
76if.then:
77  br i1 false, label %firstphiblock, label %temp
78firstphiblock:
79  %firstphi = phi i64 [ %arg, %if.then ], [ %secondphi, %secondphiblock ]
80  br i1 undef, label %for.cond17thread-pre-split, label %secondphiblock
81secondphiblock:
82  %secondphi = phi i64 [ %thirdphi, %thirdphiblock ], [ %firstphi, %firstphiblock ]
83  br i1 undef, label %firstphiblock, label %thirdphiblock
84thirdphiblock:
85  %thirdphi = phi i64 [ %secondphi, %secondphiblock ], [ %div, %cond.true ]
86  br label %secondphiblock
87for.cond17thread-pre-split:
88  br label %cond.true
89cond.true:
90  %fourthphi = phi i64 [ %arg, %entry ], [ %firstphi, %for.cond17thread-pre-split ]
91  %div = sdiv i64 %fourthphi, 4
92  br label %thirdphiblock
93temp:
94  ret void
95}
96@b = external global i32, align 4
97@a = external global i32, align 4
98define void @fn3() {
99; CHECK-LABEL: @fn3(
100; CHECK-NEXT:  entry:
101; CHECK-NEXT:    br label [[L1:%.*]]
102; CHECK:       l1.loopexit:
103; CHECK-NEXT:    br label [[L1]]
104; CHECK:       l1:
105; CHECK-NEXT:    [[F_0:%.*]] = phi i32* [ @b, [[ENTRY:%.*]] ], [ @a, [[L1_LOOPEXIT:%.*]] ]
106; CHECK-NEXT:    br label [[FOR_COND:%.*]]
107; CHECK:       for.cond.loopexit:
108; CHECK-NEXT:    store i8 undef, i8* null
109; CHECK-NEXT:    br label [[FOR_COND]]
110; CHECK:       for.cond:
111; CHECK-NEXT:    br i1 undef, label [[FOR_END14:%.*]], label [[FOR_COND1_PREHEADER:%.*]]
112; CHECK:       for.cond1.preheader:
113; CHECK-NEXT:    br label [[FOR_BODY3:%.*]]
114; CHECK:       for.cond1:
115; CHECK-NEXT:    br label [[L2:%.*]]
116; CHECK:       for.body3:
117; CHECK-NEXT:    br i1 undef, label [[FOR_COND1:%.*]], label [[L1_LOOPEXIT]]
118; CHECK:       l2:
119; CHECK-NEXT:    [[G_4:%.*]] = phi i32* [ @b, [[FOR_END14]] ], [ @a, [[FOR_COND1]] ]
120; CHECK-NEXT:    [[F_2:%.*]] = phi i32* [ [[F_0]], [[FOR_END14]] ], [ @a, [[FOR_COND1]] ]
121; CHECK-NEXT:    br label [[FOR_INC:%.*]]
122; CHECK:       for.inc:
123; CHECK-NEXT:    br i1 false, label [[FOR_COND_LOOPEXIT:%.*]], label [[FOR_INC]]
124; CHECK:       for.end14:
125; CHECK-NEXT:    br label [[L2]]
126;
127entry:
128  br label %l1
129l1.loopexit:
130  %g.223.lcssa = phi i32* [ @b, %for.body3 ]
131  br label %l1
132l1:
133  %g.0 = phi i32* [ undef, %entry ], [ %g.223.lcssa, %l1.loopexit ]
134  %f.0 = phi i32* [ @b, %entry ], [ @a, %l1.loopexit ]
135  br label %for.cond
136for.cond.loopexit:
137  br label %for.cond
138for.cond:
139  %g.1 = phi i32* [ %g.0, %l1 ], [ %g.4, %for.cond.loopexit ]
140  %f.1 = phi i32* [ %f.0, %l1 ], [ %f.2, %for.cond.loopexit ]
141  br i1 undef, label %for.end14, label %for.cond1.preheader
142for.cond1.preheader:
143  br label %for.body3
144for.cond1:
145  br label %l2
146for.body3:
147  br i1 undef, label %for.cond1, label %l1.loopexit
148l2:
149  %g.4 = phi i32* [ %g.1, %for.end14 ], [ @a, %for.cond1 ]
150  %f.2 = phi i32* [ %f.1, %for.end14 ], [ @a, %for.cond1 ]
151  br label %for.inc
152for.inc:
153  br i1 false, label %for.cond.loopexit, label %for.inc
154for.end14:
155  br label %l2
156}
157
158