64 lines · plain
1; RUN: opt %loadNPMPolly '-passes=polly-custom<scops>' -polly-print-detect -polly-print-scops -polly-invariant-load-hoisting=true -disable-output < %s 2>&1 | FileCheck %s2;3; Negative test. If we assume UB[*V] to be invariant we get a cyclic4; dependence in the invariant loads that needs to be resolved by5; ignoring the actual accessed address and focusing on the fact6; that the access happened. However, at the moment we assume UB[*V]7; not to be loop invariant, thus reject this region.8;9; CHECK-NOT: Statements10;11;12; void f(int *restrict V, int *restrict UB, int *restrict A) {13; for (int i = 0; i < 100; i++) {14; int j = 0;15; int x = 0;16; do {17; x = /* invariant load dependent on UB[*V] */ *V;18; A[j + i]++;19; } while (j++ < /* invariant load dependent on *V */ UB[x]);20; }21; }22;23target datalayout = "e-m:e-i32:64-f80:128-n8:16:32:64-S128"24 25define void @f(ptr noalias %V, ptr noalias %UB, ptr noalias %A) {26entry:27 br label %for.cond28 29for.cond: ; preds = %for.inc, %entry30 %indvars.iv2 = phi i32 [ %indvars.iv.next3, %for.inc ], [ 0, %entry ]31 %exitcond = icmp ne i32 %indvars.iv2, 10032 br i1 %exitcond, label %for.body, label %for.end33 34for.body: ; preds = %for.cond35 br label %do.body36 37do.body: ; preds = %do.cond, %for.body38 %indvars.iv = phi i32 [ %indvars.iv.next, %do.cond ], [ 0, %for.body ]39 %tmp = load i32, ptr %V, align 440 %tmp4 = add nuw nsw i32 %indvars.iv, %indvars.iv241 %arrayidx = getelementptr inbounds i32, ptr %A, i32 %tmp442 %tmp5 = load i32, ptr %arrayidx, align 443 %inc = add nsw i32 %tmp5, 144 store i32 %inc, ptr %arrayidx, align 445 br label %do.cond46 47do.cond: ; preds = %do.body48 %indvars.iv.next = add nuw nsw i32 %indvars.iv, 149 %arrayidx3 = getelementptr inbounds i32, ptr %UB, i32 %tmp50 %tmp6 = load i32, ptr %arrayidx3, align 451 %cmp4 = icmp slt i32 %indvars.iv, %tmp652 br i1 %cmp4, label %do.body, label %do.end53 54do.end: ; preds = %do.cond55 br label %for.inc56 57for.inc: ; preds = %do.end58 %indvars.iv.next3 = add nuw nsw i32 %indvars.iv2, 159 br label %for.cond60 61for.end: ; preds = %for.cond62 ret void63}64