1 ; RUN: opt %loadPolly -analyze -polly-scops -polly-invariant-load-hoisting=true < %s | FileCheck %s
3 ; Negative test. If we assume UB[*V] to be invariant we get a cyclic
4 ; dependence in the invariant loads that needs to be resolved by
5 ; ignoring the actual accessed address and focusing on the fact
6 ; that the access happened. However, at the moment we assume UB[*V]
7 ; not to be loop invariant, thus reject this region.
9 ; CHECK-NOT: Statements
12 ; void f(int *restrict V, int *restrict UB, int *restrict A) {
13 ; for (int i = 0; i < 100; i++) {
17 ; x = /* invariant load dependent on UB[*V] */ *V;
19 ; } while (j++ < /* invariant load dependent on *V */ UB[x]);
23 target datalayout = "e-m:e-i32:64-f80:128-n8:16:32:64-S128"
25 define void @f(i32* noalias %V, i32* noalias %UB, i32* noalias %A) {
29 for.cond: ; preds = %for.inc, %entry
30 %indvars.iv2 = phi i32 [ %indvars.iv.next3, %for.inc ], [ 0, %entry ]
31 %exitcond = icmp ne i32 %indvars.iv2, 100
32 br i1 %exitcond, label %for.body, label %for.end
34 for.body: ; preds = %for.cond
37 do.body: ; preds = %do.cond, %for.body
38 %indvars.iv = phi i32 [ %indvars.iv.next, %do.cond ], [ 0, %for.body ]
39 %tmp = load i32, i32* %V, align 4
40 %tmp4 = add nuw nsw i32 %indvars.iv, %indvars.iv2
41 %arrayidx = getelementptr inbounds i32, i32* %A, i32 %tmp4
42 %tmp5 = load i32, i32* %arrayidx, align 4
43 %inc = add nsw i32 %tmp5, 1
44 store i32 %inc, i32* %arrayidx, align 4
47 do.cond: ; preds = %do.body
48 %indvars.iv.next = add nuw nsw i32 %indvars.iv, 1
49 %arrayidx3 = getelementptr inbounds i32, i32* %UB, i32 %tmp
50 %tmp6 = load i32, i32* %arrayidx3, align 4
51 %cmp4 = icmp slt i32 %indvars.iv, %tmp6
52 br i1 %cmp4, label %do.body, label %do.end
54 do.end: ; preds = %do.cond
57 for.inc: ; preds = %do.end
58 %indvars.iv.next3 = add nuw nsw i32 %indvars.iv2, 1
61 for.end: ; preds = %for.cond