64 lines · plain
1; RUN: opt %loadNPMPolly '-passes=polly-custom<scops>' -polly-print-scops -disable-output < %s 2>&1 | FileCheck %s2;3; The assumed context is tricky here as the equality test for the inner loop4; allows an "unbounded" loop trip count. We assume that does not happen, thus5; if N <= 1 the outer loop is not executed and we are done, if N >= 3 the6; equality test in the inner exit condition will trigger at some point and,7; finally, if N == 2 we would have an unbounded inner loop.8;9; CHECK: Assumed Context:10; CHECK-NEXT: [N] -> { : }11; CHECK: Invalid Context:12; CHECK-NEXT: [N] -> { : N = 2 }13;14; int jd(int *restrict A, int x, int N) {15; for (int i = 1; i < N; i++)16; for (int j = 3; j < N; j++)17; x += A[i];18; return x;19; }20;21target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"22 23define i32 @jd(ptr noalias %A, i32 %x, i32 %N) {24entry:25 %tmp = sext i32 %N to i6426 br label %for.cond27 28for.cond: ; preds = %for.inc4, %entry29 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc4 ], [ 1, %entry ]30 %x.addr.0 = phi i32 [ %x, %entry ], [ %x.addr.1.lcssa, %for.inc4 ]31 %cmp = icmp slt i64 %indvars.iv, %tmp32 br i1 %cmp, label %for.body, label %for.end633 34for.body: ; preds = %for.cond35 br label %for.cond136 37for.cond1: ; preds = %for.inc, %for.body38 %x.addr.1 = phi i32 [ %x.addr.0, %for.body ], [ %add, %for.inc ]39 %j.0 = phi i32 [ 3, %for.body ], [ %inc, %for.inc ]40 %exitcond = icmp ne i32 %j.0, %N41 br i1 %exitcond, label %for.body3, label %for.end42 43for.body3: ; preds = %for.cond144 br label %for.inc45 46for.inc: ; preds = %for.body347 %arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv48 %tmp1 = load i32, ptr %arrayidx, align 449 %add = add nsw i32 %x.addr.1, %tmp150 %inc = add i32 %j.0, 151 br label %for.cond152 53for.end: ; preds = %for.cond154 %x.addr.1.lcssa = phi i32 [ %x.addr.1, %for.cond1 ]55 br label %for.inc456 57for.inc4: ; preds = %for.end58 %indvars.iv.next = add i64 %indvars.iv, 159 br label %for.cond60 61for.end6: ; preds = %for.cond62 ret i32 %x.addr.063}64