95 lines · plain
1; RUN: opt %loadNPMPolly -aa-pipeline=basic-aa '-passes=polly-custom<scops>' -polly-print-scops -disable-output -polly-precise-inbounds < %s 2>&1 | FileCheck %s2;3; void foo(float A[restrict][20], float B[restrict][20], long n, long m,4; long p) {5; for (long i = 0; i < n; i++)6; for (long j = 0; j < m; j++)7; A[i][j] = i + j;8; for (long i = 0; i < m; i++)9; for (long j = 0; j < p; j++)10; B[i][j] = i + j;11; }12 13; This code is within bounds either if m and p are smaller than the array sizes,14; but also if only p is smaller than the size of the second B dimension and n15; is such that the first loop is never executed and consequently A is never16; accessed. In this case the value of m does not matter.17 18; CHECK: Assumed Context:19; CHECK-NEXT: [n, m, p] -> { : p <= 20 and (n <= 0 or (n > 0 and m <= 20)) }20 21target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"22 23define void @foo(ptr noalias %A, ptr noalias %B, i64 %n, i64 %m, i64 %p) {24entry:25 br label %for.cond26 27for.cond: ; preds = %for.inc5, %entry28 %i.0 = phi i64 [ 0, %entry ], [ %inc6, %for.inc5 ]29 %cmp = icmp slt i64 %i.0, %n30 br i1 %cmp, label %for.body, label %for.end731 32for.body: ; preds = %for.cond33 br label %for.cond134 35for.cond1: ; preds = %for.inc, %for.body36 %j.0 = phi i64 [ 0, %for.body ], [ %inc, %for.inc ]37 %cmp2 = icmp slt i64 %j.0, %m38 br i1 %cmp2, label %for.body3, label %for.end39 40for.body3: ; preds = %for.cond141 %add = add nsw i64 %i.0, %j.042 %conv = sitofp i64 %add to float43 %arrayidx4 = getelementptr inbounds [20 x float], ptr %A, i64 %i.0, i64 %j.044 store float %conv, ptr %arrayidx4, align 445 br label %for.inc46 47for.inc: ; preds = %for.body348 %inc = add nsw i64 %j.0, 149 br label %for.cond150 51for.end: ; preds = %for.cond152 br label %for.inc553 54for.inc5: ; preds = %for.end55 %inc6 = add nsw i64 %i.0, 156 br label %for.cond57 58for.end7: ; preds = %for.cond59 br label %for.cond960 61for.cond9: ; preds = %for.inc25, %for.end762 %i8.0 = phi i64 [ 0, %for.end7 ], [ %inc26, %for.inc25 ]63 %cmp10 = icmp slt i64 %i8.0, %m64 br i1 %cmp10, label %for.body12, label %for.end2765 66for.body12: ; preds = %for.cond967 br label %for.cond1468 69for.cond14: ; preds = %for.inc22, %for.body1270 %j13.0 = phi i64 [ 0, %for.body12 ], [ %inc23, %for.inc22 ]71 %cmp15 = icmp slt i64 %j13.0, %p72 br i1 %cmp15, label %for.body17, label %for.end2473 74for.body17: ; preds = %for.cond1475 %add18 = add nsw i64 %i8.0, %j13.076 %conv19 = sitofp i64 %add18 to float77 %arrayidx21 = getelementptr inbounds [20 x float], ptr %B, i64 %i8.0, i64 %j13.078 store float %conv19, ptr %arrayidx21, align 479 br label %for.inc2280 81for.inc22: ; preds = %for.body1782 %inc23 = add nsw i64 %j13.0, 183 br label %for.cond1484 85for.end24: ; preds = %for.cond1486 br label %for.inc2587 88for.inc25: ; preds = %for.end2489 %inc26 = add nsw i64 %i8.0, 190 br label %for.cond991 92for.end27: ; preds = %for.cond993 ret void94}95