1; RUN: opt %loadNPMPolly -polly-parallel '-passes=print<polly-ast>' -disable-output < %s | FileCheck %s -check-prefix=AST 2; RUN: opt %loadNPMPolly -polly-parallel -passes=polly-codegen -S < %s | FileCheck %s -check-prefix=IR 3; 4; float A[100]; 5; 6; void loop_references_outer_ids(long n) { 7; for (long i = 0; i < 100; i++) 8; for (long j = 0; j < 100; j++) 9; for (long k = 0; k < n + i; k++) 10; A[j] += i + j + k; 11; } 12 13; In this test case we verify that the j-loop is generated as OpenMP parallel 14; loop and that the values of 'i' and 'n', needed in the loop bounds of the 15; k-loop, are correctly passed to the subfunction. 16 17; AST: #pragma minimal dependence distance: 1 18; AST: for (int c0 = max(0, -n + 1); c0 <= 99; c0 += 1) 19; AST: #pragma omp parallel for 20; AST: for (int c1 = 0; c1 <= 99; c1 += 1) 21; AST: #pragma minimal dependence distance: 1 22; AST: for (int c2 = 0; c2 < n + c0; c2 += 1) 23; AST: Stmt_for_body6(c0, c1, c2); 24 25; IR: %polly.par.userContext = alloca { i64, i64 } 26; IR: %[[R1:[0-9a-z.]+]] = getelementptr inbounds nuw { i64, i64 }, ptr %polly.par.userContext, i32 0, i32 0 27; IR-NEXT: store i64 %n, ptr %[[R1]] 28; IR-NEXT: %[[R2:[0-9a-z.]+]] = getelementptr inbounds nuw { i64, i64 }, ptr %polly.par.userContext, i32 0, i32 1 29; IR-NEXT: store i64 %polly.indvar, ptr %[[R2]] 30 31; IR-LABEL: @loop_references_outer_ids_polly_subfn(ptr %polly.par.userContext) 32; IR: %[[R3:[0-9a-z.]+]] = getelementptr inbounds nuw { i64, i64 }, ptr %polly.par.userContext, i32 0, i32 0 33; IR-NEXT: %[[R4:[0-9a-z.]+]] = load i64, ptr %[[R3]] 34; IR-NEXT: %[[R5:[0-9a-z.]+]] = getelementptr inbounds nuw { i64, i64 }, ptr %polly.par.userContext, i32 0, i32 1 35; IR-NEXT: %[[R6:[0-9a-z.]+]] = load i64, ptr %[[R5]] 36 37target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 38 39@A = common global [100 x float] zeroinitializer, align 16 40 41define void @loop_references_outer_ids(i64 %n) { 42entry: 43 br label %for.cond 44 45for.cond: ; preds = %for.inc03, %entry 46 %i.0 = phi i64 [ 0, %entry ], [ %inc04, %for.inc03 ] 47 %exitcond1 = icmp ne i64 %i.0, 100 48 br i1 %exitcond1, label %for.body, label %for.end15 49 50for.body: ; preds = %for.cond 51 br label %for.cond1 52 53for.cond1: ; preds = %for.inc00, %for.body 54 %j.0 = phi i64 [ 0, %for.body ], [ %inc01, %for.inc00 ] 55 %exitcond = icmp ne i64 %j.0, 100 56 br i1 %exitcond, label %for.body3, label %for.end12 57 58for.body3: ; preds = %for.cond1 59 br label %for.cond4 60 61for.cond4: ; preds = %for.inc, %for.body3 62 %k.0 = phi i64 [ 0, %for.body3 ], [ %inc, %for.inc ] 63 %add = add nsw i64 %i.0, %n 64 %cmp5 = icmp slt i64 %k.0, %add 65 br i1 %cmp5, label %for.body6, label %for.end 66 67for.body6: ; preds = %for.cond4 68 %add7 = add nsw i64 %i.0, %j.0 69 %add8 = add nsw i64 %add7, %k.0 70 %conv = sitofp i64 %add8 to float 71 %arrayidx = getelementptr inbounds [100 x float], ptr @A, i64 0, i64 %j.0 72 %tmp = load float, ptr %arrayidx, align 4 73 %add9 = fadd float %tmp, %conv 74 store float %add9, ptr %arrayidx, align 4 75 br label %for.inc 76 77for.inc: ; preds = %for.body6 78 %inc = add nsw i64 %k.0, 1 79 br label %for.cond4 80 81for.end: ; preds = %for.cond4 82 br label %for.inc00 83 84for.inc00: ; preds = %for.end 85 %inc01 = add nsw i64 %j.0, 1 86 br label %for.cond1 87 88for.end12: ; preds = %for.cond1 89 br label %for.inc03 90 91for.inc03: ; preds = %for.end12 92 %inc04 = add nsw i64 %i.0, 1 93 br label %for.cond 94 95for.end15: ; preds = %for.cond 96 ret void 97} 98