1 ; RUN: opt %loadPolly -polly-use-llvm-names -polly-scops \ 2; RUN: -polly-invariant-load-hoisting -polly-codegen-ppcg \ 3; RUN: -polly-acc-dump-code -disable-output \ 4; RUN: < %s | FileCheck %s -check-prefix=CODE 5 6; RUN: opt %loadPolly -polly-use-llvm-names -polly-scops \ 7; RUN: -polly-invariant-load-hoisting -polly-codegen-ppcg \ 8; RUN: -polly-acc-dump-kernel-ir -disable-output \ 9; RUN: < %s | FileCheck %s -check-prefix=KERNELIR 10 11; REQUIRES: pollyacc 12 13; void f(const int *end, int *arr, const int *control, const int *readarr) { 14; for (int i = 0; i < *end; i++) { 15; int t = 0; 16; if (*control > 3) { 17; t += readarr[i]; 18; } 19; arr[i] = t; 20; } 21; } 22 23; This test case tests the ability to infer that `t` is local to each loop 24; iteration, and can therefore be privatized. 25 26; CODE: # kernel0 27; CODE-NEXT: for (int c0 = 0; c0 <= (tmp - 32 * b0 - 1) / 1048576; c0 += 1) 28; CODE-NEXT: if (tmp >= 32 * b0 + t0 + 1048576 * c0 + 1) { 29; CODE-NEXT: Stmt_for_body_last(32 * b0 + t0 + 1048576 * c0); 30; CODE-NEXT: if (tmp1 >= 4) 31; CODE-NEXT: Stmt_if_then(32 * b0 + t0 + 1048576 * c0); 32; CODE-NEXT: Stmt_if_end(32 * b0 + t0 + 1048576 * c0); 33; CODE-NEXT: } 34 35; KERNELIR: %private_array = alloca i32 36 37target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128" 38target triple = "i386-apple-macosx10.12.0" 39 40define void @f(i32* %end, i32* %arr, i32* %control, i32* %readarr) { 41entry: 42 br label %entry.split 43 44entry.split: ; preds = %entry 45 %tmp3 = load i32, i32* %end, align 4 46 %cmp4 = icmp sgt i32 %tmp3, 0 47 br i1 %cmp4, label %for.body.lr.ph, label %for.end 48 49for.body.lr.ph: ; preds = %entry.split 50 br label %for.body 51 52for.body: ; preds = %for.body.lr.ph, %if.end 53 %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %if.end ] 54 %tmp1 = load i32, i32* %control, align 4 55 %cmp1 = icmp sgt i32 %tmp1, 3 56 br i1 %cmp1, label %if.then, label %if.end 57 58if.then: ; preds = %for.body 59 %arrayidx = getelementptr inbounds i32, i32* %readarr, i32 %i.05 60 %tmp2 = load i32, i32* %arrayidx, align 4 61 br label %if.end 62 63if.end: ; preds = %if.then, %for.body 64 %t.0 = phi i32 [ %tmp2, %if.then ], [ 0, %for.body ] 65 %arrayidx2 = getelementptr inbounds i32, i32* %arr, i32 %i.05 66 store i32 %t.0, i32* %arrayidx2, align 4 67 %inc = add nuw nsw i32 %i.05, 1 68 %tmp = load i32, i32* %end, align 4 69 %cmp = icmp slt i32 %inc, %tmp 70 br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge 71 72for.cond.for.end_crit_edge: ; preds = %if.end 73 br label %for.end 74 75for.end: ; preds = %for.cond.for.end_crit_edge, %entry.split 76 ret void 77} 78 79