xref: /llvm-project/polly/test/CodeGen/phi_in_exit_early_lnt_failure_3.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly -passes=polly-codegen -S < %s | FileCheck %s
2;
3; This caused an lnt crash at some point, just verify it will run through and
4; produce the PHI node in the exit we are looking for.
5;
6; CHECK-LABEL: polly.merge_new_and_old:
7; CHECK-NEXT:     %n2ptr.2.ph.merge = phi ptr [ %n2ptr.2.ph.final_reload, %polly.exiting ], [ %n2ptr.2.ph, %if.end.45.region_exiting ]
8;
9; CHECK-LABEL: if.end.45:
10; CHECK-NEXT:     %n2ptr.2 = phi ptr [ %add.ptr25, %entry ], [ %add.ptr25, %while.cond.preheader ], [ %n2ptr.2.ph.merge, %polly.merge_new_and_old ]
11
12%struct.bc_struct.0.2.4.6.8.15.24.27.29.32.38.46.48.92.93.94.95.97.99.100.102.105.107.111.118.119.121 = type { i32, i32, i32, i32, [1024 x i8] }
13
14; Function Attrs: nounwind uwtable
15declare ptr @new_num() #0
16
17; Function Attrs: nounwind uwtable
18define void @_do_add(ptr %n2) #0 {
19entry:
20  %call = tail call ptr @new_num()
21  %0 = load i32, ptr undef, align 4
22  %add.ptr22 = getelementptr inbounds %struct.bc_struct.0.2.4.6.8.15.24.27.29.32.38.46.48.92.93.94.95.97.99.100.102.105.107.111.118.119.121, ptr %n2, i64 0, i32 4, i64 0
23  %add.ptr25 = getelementptr inbounds i8, ptr %add.ptr22, i64 -1
24  %add.ptr29 = getelementptr inbounds %struct.bc_struct.0.2.4.6.8.15.24.27.29.32.38.46.48.92.93.94.95.97.99.100.102.105.107.111.118.119.121, ptr %call, i64 0, i32 4, i64 0
25  %add.ptr32 = getelementptr inbounds i8, ptr %add.ptr29, i64 -1
26  br i1 undef, label %if.end.45, label %if.then
27
28if.then:                                          ; preds = %entry
29  br i1 undef, label %while.cond.preheader, label %while.cond.38.preheader
30
31while.cond.38.preheader:                          ; preds = %if.then
32  %cmp39.39 = icmp sgt i32 %0, 0
33  br i1 %cmp39.39, label %while.body.40.lr.ph, label %if.end.45
34
35while.body.40.lr.ph:                              ; preds = %while.cond.38.preheader
36  br label %while.body.40
37
38while.cond.preheader:                             ; preds = %if.then
39  br i1 undef, label %while.body.lr.ph, label %if.end.45
40
41while.body.lr.ph:                                 ; preds = %while.cond.preheader
42  br label %while.body
43
44while.body:                                       ; preds = %while.body, %while.body.lr.ph
45  br label %while.body
46
47while.body.40:                                    ; preds = %while.body.40, %while.body.40.lr.ph
48  %sumptr.141 = phi ptr [ %add.ptr32, %while.body.40.lr.ph ], [ %incdec.ptr42, %while.body.40 ]
49  %n2ptr.040 = phi ptr [ %add.ptr25, %while.body.40.lr.ph ], [ %incdec.ptr41, %while.body.40 ]
50  %incdec.ptr41 = getelementptr inbounds i8, ptr %n2ptr.040, i64 -1
51  %1 = load i8, ptr %n2ptr.040, align 1
52  %incdec.ptr42 = getelementptr inbounds i8, ptr %sumptr.141, i64 -1
53  store i8 %1, ptr %sumptr.141, align 1
54  br i1 false, label %while.body.40, label %while.cond.38.if.end.45.loopexit9_crit_edge
55
56while.cond.38.if.end.45.loopexit9_crit_edge:      ; preds = %while.body.40
57  br label %if.end.45
58
59if.end.45:                                        ; preds = %while.cond.38.if.end.45.loopexit9_crit_edge, %while.cond.preheader, %while.cond.38.preheader, %entry
60  %n2ptr.2 = phi ptr [ %add.ptr25, %entry ], [ %add.ptr25, %while.cond.preheader ], [ undef, %while.cond.38.if.end.45.loopexit9_crit_edge ], [ %add.ptr25, %while.cond.38.preheader ]
61  ret void
62}
63