brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · 73a7c59 Raw
95 lines · plain
1; RUN: opt %loadNPMPolly '-passes=polly-custom<ast>' -polly-print-ast -polly-precise-inbounds -polly-precise-fold-accesses -disable-output < %s | FileCheck %s2 3target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"4 5; void foo(long n, long m, int o, double A[n][m], long p, long q) {6;7; if (o >= 0)8;   for (long i = 0; i < n; i++)9;     for (long j = 0; j < m; j++)10;         A[i+p][j+q] = 1.0;11; else12;   for (long i = 0; i < n; i++)13;     for (long j = 0; j < m; j++)14;         A[i+p][j+q-100] = 1.0;15;16 17; This test case is meant to verify that the run-time condition generated18; for the delinearization is simplified such that conditions that would not19; cause any code to be executed are not generated.20 21; CHECK: if (((o >= 1 && q <= 0 && m + q >= 0) || (o <= 0 && m + q >= 100 && q <= 100)) && 0 == ((o <= 0 && n >= 1 && m + q >= 9223372036854775909) || (o <= 0 && m >= 1 && n >= 1 && q <= -9223372036854775709)))22 23; CHECK:     if (o <= 0) {24; CHECK:       for (int c0 = 0; c0 < n; c0 += 1)25; CHECK:         for (int c1 = 0; c1 < m; c1 += 1)26; CHECK:           Stmt_for_j_1(c0, c1);27; CHECK:     } else28; CHECK:       for (int c0 = 0; c0 < n; c0 += 1)29; CHECK:         for (int c1 = 0; c1 < m; c1 += 1)30; CHECK:           Stmt_for_j(c0, c1);31 32; CHECK: else33; CHECK:     {  /* original code */ }34 35define void @foo(i64 %n, i64 %m, i64 %o, ptr %A, i64 %p, i64 %q) {36entry:37  br label %cond38 39cond:40  %cmp = icmp sgt i64 %o, 041  br i1 %cmp, label %for.i, label %for.i.142 43for.i:44  %i = phi i64 [ 0, %cond ], [ %i.inc, %for.i.inc ]45  br label %for.j46 47for.j:48  %j = phi i64 [ 0, %for.i ], [ %j.inc, %for.j.inc ]49  %offset0 = add nsw i64 %i, %p50  %subscript0 = mul i64 %offset0, %m51  %offset1 = add nsw i64 %j, %q52  %subscript1 = add i64 %offset1, %subscript053  %idx = getelementptr inbounds double, ptr %A, i64 %subscript154  store double 1.0, ptr %idx55  br label %for.j.inc56 57for.j.inc:58  %j.inc = add nsw i64 %j, 159  %j.exitcond = icmp eq i64 %j.inc, %m60  br i1 %j.exitcond, label %for.i.inc, label %for.j61 62for.i.inc:63  %i.inc = add nsw i64 %i, 164  %i.exitcond = icmp eq i64 %i.inc, %n65  br i1 %i.exitcond, label %end, label %for.i66 67for.i.1:68  %i.1 = phi i64 [ 0, %cond ], [ %i.inc.1, %for.i.inc.1 ]69  br label %for.j.170 71for.j.1:72  %j.1 = phi i64 [ 0, %for.i.1 ], [ %j.inc.1, %for.j.inc.1 ]73  %offset0.1 = add nsw i64 %i.1, %p74  %subscript0.1 = mul i64 %offset0.1, %m75  %offset1.1 = add nsw i64 %j.1, %q76  %subscript1.1 = add i64 %offset1.1, %subscript0.177  %subscript1.2 = sub i64 %subscript1.1, 10078  %idx.1 = getelementptr inbounds double, ptr %A, i64 %subscript1.279  store double 1.0, ptr %idx.180  br label %for.j.inc.181 82for.j.inc.1:83  %j.inc.1 = add nsw i64 %j.1, 184  %j.exitcond.1 = icmp eq i64 %j.inc.1, %m85  br i1 %j.exitcond.1, label %for.i.inc.1, label %for.j.186 87for.i.inc.1:88  %i.inc.1 = add nsw i64 %i.1, 189  %i.exitcond.1 = icmp eq i64 %i.inc.1, %n90  br i1 %i.exitcond.1, label %end, label %for.i.191 92end:93  ret void94}95