brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · b147597 Raw
75 lines · plain
1; RUN: opt %loadNPMPolly '-passes=polly<no-default-opts>' -polly-allow-nonaffine-loops -polly-allow-nonaffine -debug-only=polly-dependence < %s 2>&1 | FileCheck %s2; REQUIRES: asserts3 4; CHECK:        MayWriteAccess :=   [Reduction Type: NONE] [Scalar: 0]5; CHECK-NEXT:       { Stmt_for_body__TO__for_inc11[i0] -> MemRef_A[o0] : 0 <= o0 <= 699 };6; CHECK-NEXT:   MayWriteAccess :=   [Reduction Type: NONE] [Scalar: 0]7; CHECK-NEXT:       { Stmt_for_body__TO__for_inc11[i0] -> MemRef_B[700] };8 9; The if condition C[i] is a non-affine condition, which make the nested loop boxed. The memory access for A should be a range A[0...699]. The memory access for B should be simplified to B[700].10;11; int A[1000], B[1000], C[1000];12;13; void foo(int n, int m, int N) {14;   for (int i = 0; i < 500; i+=1) { /* affine loop */15;      C[i] += i;16;      if (C[i]) { /* non-affine subregion */17;          int j;18;          for (j = 0; j < 700; j+=1) { /* boxed loop */19;            A[j] = 1;20;          }21;          B[j] = 2;22;      }23;    }24; }25 26 27target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"28 29@C = common global [1000 x i32] zeroinitializer, align 430@A = common global [1000 x i32] zeroinitializer, align 431@B = common global [1000 x i32] zeroinitializer, align 432 33; Function Attrs: norecurse nounwind34define void @foo(i32 %n, i32 %m, i32 %N) #0 {35entry:36  br label %entry.split37 38entry.split:                                      ; preds = %entry39  br label %for.body40 41for.cond.cleanup:                                 ; preds = %for.inc1142  ret void43 44for.body:                                         ; preds = %for.inc11, %entry.split45  %indvars.iv25 = phi i64 [ 0, %entry.split ], [ %indvars.iv.next26, %for.inc11 ]46  %arrayidx = getelementptr inbounds [1000 x i32], ptr @C, i64 0, i64 %indvars.iv2547  %0 = load i32, ptr %arrayidx, align 448  %1 = trunc i64 %indvars.iv25 to i3249  %add = add nsw i32 %0, %150  store i32 %add, ptr %arrayidx, align 451  %tobool = icmp eq i32 %add, 052  br i1 %tobool, label %for.inc11, label %for.body5.preheader53 54for.body5.preheader:                              ; preds = %for.body55  br label %for.body556 57for.body5:                                        ; preds = %for.body5.preheader, %for.body558  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body5 ], [ 0, %for.body5.preheader ]59  %arrayidx7 = getelementptr inbounds [1000 x i32], ptr @A, i64 0, i64 %indvars.iv60  store i32 1, ptr %arrayidx7, align 461  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 162  %exitcond = icmp eq i64 %indvars.iv, 69963  br i1 %exitcond, label %for.end, label %for.body564 65for.end:                                          ; preds = %for.body566  store i32 2, ptr getelementptr inbounds ([1000 x i32], ptr @B, i64 0, i64 700), align 467  br label %for.inc1168 69for.inc11:                                        ; preds = %for.body, %for.end70  %indvars.iv.next26 = add nuw nsw i64 %indvars.iv25, 171  %exitcond27 = icmp eq i64 %indvars.iv25, 49972  br i1 %exitcond27, label %for.cond.cleanup, label %for.body73}74 75