1 ; RUN: opt %loadNPMPolly '-passes=print<polly-detect>' -disable-output < %s 2>&1 | FileCheck %s
3 ; Region with an exit node that has a PHI node multiple incoming edges from
4 ; inside the region. Motivation for supporting such cases in Polly.
6 ; float test(long n, float A[static const restrict n]) {
8 ; for (long i = 0; i < n; i += 1)
10 ; for (long i = 0; i < n; i += 1)
17 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
19 define float @test(i64 %n, ptr noalias nonnull %A) {
23 for.cond: ; preds = %for.inc, %entry
24 %sum.0 = phi float [ 0.000000e+00, %entry ], [ %add, %for.inc ]
25 %i.0 = phi i64 [ 0, %entry ], [ %add1, %for.inc ]
26 %cmp = icmp slt i64 %i.0, %n
27 br i1 %cmp, label %for.body, label %for.end
29 for.body: ; preds = %for.cond
32 for.inc: ; preds = %for.body
33 %arrayidx = getelementptr inbounds float, ptr %A, i64 %i.0
34 %tmp = load float, ptr %arrayidx, align 4
35 %add = fadd float %sum.0, %tmp
36 %add1 = add nuw nsw i64 %i.0, 1
39 for.end: ; preds = %for.cond
40 %sum.0.lcssa = phi float [ %sum.0, %for.cond ]
43 for.cond.3: ; preds = %for.inc.8, %for.end
44 %sum.1 = phi float [ %sum.0.lcssa, %for.end ], [ %add7, %for.inc.8 ]
45 %i2.0 = phi i64 [ 0, %for.end ], [ %add9, %for.inc.8 ]
46 %cmp4 = icmp slt i64 %i2.0, %n
47 br i1 %cmp4, label %for.body.5, label %for.end.10
49 for.body.5: ; preds = %for.cond.3
52 for.inc.8: ; preds = %for.body.5
53 %arrayidx6 = getelementptr inbounds float, ptr %A, i64 %i2.0
54 %tmp1 = load float, ptr %arrayidx6, align 4
55 %add7 = fadd float %sum.1, %tmp1
56 %add9 = add nuw nsw i64 %i2.0, 1
59 for.end.10: ; preds = %for.cond.3
60 %sum.1.lcssa = phi float [ %sum.1, %for.cond.3 ]
61 ret float %sum.1.lcssa
64 ; CHECK: Valid Region for Scop: for.cond => for.end.10