xref: /llvm-project/polly/test/CodeGen/loop_with_conditional_entry_edge_split_hard_case.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly -passes=polly-codegen -S < %s | FileCheck %s
2;
3; Test case to trigger the hard way of creating a unique entering
4; edge for the SCoP. It is triggered because the entering edge
5; here: %while.begin --> %if is __not__ critical.
6;
7;    int f(void);
8;    void jd(int b, int *A) {
9;      while (f()) {
10;        if (b)
11;          for (int i = 0; i < 1024; i++)
12;            A[i] = i;
13;      }
14;    }
15;
16target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
17
18define void @jd(i32 %b, ptr %A) {
19entry:
20  br label %while.begin
21
22; CHECK-LABEL: while.begin.region_exiting:
23; CHECK:         br label %polly.merge_new_and_old
24
25; CHECK-LABEL: while.begin:
26while.begin:
27; CHECK:  %call = call i32 @f()
28  %call = call i32 @f()
29; CHECK:  %tobool = icmp eq i32 %call, 0
30  %tobool = icmp eq i32 %call, 0
31; CHECK:  br i1 %tobool, label %while.end, label %polly.split_new_and_old
32  br i1 %tobool, label %while.end, label %if
33
34; CHECK: polly.split_new_and_old:
35; CHECK:   br i1 true, label %polly.start, label %if
36
37; CHECK: if:
38if:                                               ; preds = %while.begin
39; CHECK: %tobool2 = icmp eq i32 %b, 0
40  %tobool2 = icmp eq i32 %b, 0
41; CHECK: br i1 %tobool2, label %while.begin{{[a-zA-Z._]*}}, label %for.cond
42  br i1 %tobool2, label %while.begin, label %for.cond
43
44for.cond:                                         ; preds = %for.inc, %if
45  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %if ]
46  %exitcond = icmp ne i64 %indvars.iv, 1024
47  br i1 %exitcond, label %for.body, label %while.begin
48
49for.body:                                         ; preds = %for.cond
50  %arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
51  %tmp = trunc i64 %indvars.iv to i32
52  store i32 %tmp, ptr %arrayidx, align 4
53  br label %for.inc
54
55for.inc:                                          ; preds = %for.body
56  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
57  br label %for.cond
58
59while.end:                                        ; preds = %entry, %for.cond
60  ret void
61}
62
63declare i32 @f()
64