1 ; RUN: opt %loadNPMPolly -polly-stmt-granularity=bb '-passes=print<polly-function-scops>' -polly-allow-modref-calls \
2 ; RUN: -polly-invariant-load-hoisting=true \
3 ; RUN: -disable-output < %s 2>&1 | FileCheck %s
4 ; RUN: opt %loadNPMPolly -polly-stmt-granularity=bb '-passes=print<polly-function-scops>' -polly-allow-nonaffine \
5 ; RUN: -polly-invariant-load-hoisting=true \
6 ; RUN: -polly-allow-modref-calls -disable-output < %s 2>&1 | FileCheck %s --check-prefix=NONAFFINE
8 ; TODO: We should delinearize the accesses despite the use in a call to a
9 ; readonly function. For now we verify we do not delinearize them though.
11 ; CHECK: Function: ham
12 ; CHECK-NEXT: Region: %bb12---%bb28
13 ; CHECK-NEXT: Max Loop Depth: 1
14 ; CHECK-NEXT: Invariant Accesses: {
15 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
16 ; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb12[] -> MemRef_arg1[0] };
17 ; CHECK-NEXT: Execution Context: [tmp14, p_1] -> { : }
19 ; CHECK-NEXT: Context:
20 ; CHECK-NEXT: [tmp14, p_1] -> { : -9223372036854775808 <= tmp14 <= 9223372036854775807 and -9223372036854775808 <= p_1 <= 9223372036854775807 }
21 ; CHECK-NEXT: Assumed Context:
22 ; CHECK-NEXT: [tmp14, p_1] -> { : }
23 ; CHECK-NEXT: Invalid Context:
24 ; CHECK-NEXT: [tmp14, p_1] -> { : tmp14 > 0 and (p_1 <= -1152921504606846977 or tmp14 >= 1152921504606846977 or p_1 >= 1152921504606846977 - tmp14) }
26 ; CHECK-NEXT: p1: {0,+,(0 smax %tmp)}<%bb12>
27 ; CHECK-NEXT: Arrays {
28 ; CHECK-NEXT: i64 MemRef_arg1[*]; // Element size 8
29 ; CHECK-NEXT: i64 MemRef_tmp13; // Element size 8
30 ; CHECK-NEXT: ptr MemRef_arg4[*]; // Element size 8
32 ; CHECK-NEXT: Arrays (Bounds as pw_affs) {
33 ; CHECK-NEXT: i64 MemRef_arg1[*]; // Element size 8
34 ; CHECK-NEXT: i64 MemRef_tmp13; // Element size 8
35 ; CHECK-NEXT: ptr MemRef_arg4[*]; // Element size 8
37 ; CHECK-NEXT: Alias Groups (0):
39 ; CHECK-NEXT: Statements {
40 ; CHECK-NEXT: Stmt_bb12
41 ; CHECK-NEXT: Domain :=
42 ; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb12[] };
43 ; CHECK-NEXT: Schedule :=
44 ; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb12[] -> [0, 0] };
45 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
46 ; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb12[] -> MemRef_tmp13[] };
47 ; CHECK-NEXT: Stmt_bb17
48 ; CHECK-NEXT: Domain :=
49 ; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb17[i0] : 0 <= i0 < tmp14 };
50 ; CHECK-NEXT: Schedule :=
51 ; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb17[i0] -> [1, i0] };
52 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
53 ; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb17[i0] -> MemRef_arg4[o0] };
54 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
55 ; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb17[i0] -> MemRef_arg4[p_1 + i0] };
59 ; NONAFFINE: Function: ham
60 ; NONAFFINE-NEXT: Region: %bb5---%bb32
61 ; NONAFFINE-NEXT: Max Loop Depth: 2
62 ; NONAFFINE-NEXT: Invariant Accesses: {
63 ; NONAFFINE-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
64 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb5[] -> MemRef_arg[0] };
65 ; NONAFFINE-NEXT: Execution Context: [tmp9, tmp14] -> { : }
66 ; NONAFFINE-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
67 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb12[i0] -> MemRef_arg1[0] };
68 ; NONAFFINE-NEXT: Execution Context: [tmp9, tmp14] -> { : }
70 ; NONAFFINE-NEXT: Context:
71 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { : -9223372036854775808 <= tmp9 <= 9223372036854775807 and -9223372036854775808 <= tmp14 <= 9223372036854775807 }
72 ; NONAFFINE-NEXT: Assumed Context:
73 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { : }
74 ; NONAFFINE-NEXT: Invalid Context:
75 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { : false }
76 ; NONAFFINE: p0: %tmp9
77 ; NONAFFINE-NEXT: p1: %tmp14
78 ; NONAFFINE-NEXT: Arrays {
79 ; NONAFFINE-NEXT: i64 MemRef_arg[*]; // Element size 8
80 ; NONAFFINE-NEXT: i64 MemRef_arg1[*]; // Element size 8
81 ; NONAFFINE-NEXT: i64 MemRef_tmp7; // Element size 8
82 ; NONAFFINE-NEXT: i64 MemRef_tmp8; // Element size 8
83 ; NONAFFINE-NEXT: ptr MemRef_arg4[*]; // Element size 8
85 ; NONAFFINE-NEXT: Arrays (Bounds as pw_affs) {
86 ; NONAFFINE-NEXT: i64 MemRef_arg[*]; // Element size 8
87 ; NONAFFINE-NEXT: i64 MemRef_arg1[*]; // Element size 8
88 ; NONAFFINE-NEXT: i64 MemRef_tmp7; // Element size 8
89 ; NONAFFINE-NEXT: i64 MemRef_tmp8; // Element size 8
90 ; NONAFFINE-NEXT: ptr MemRef_arg4[*]; // Element size 8
92 ; NONAFFINE-NEXT: Alias Groups (0):
94 ; NONAFFINE-NEXT: Statements {
95 ; NONAFFINE-NEXT: Stmt_bb5
96 ; NONAFFINE-NEXT: Domain :=
97 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb5[] };
98 ; NONAFFINE-NEXT: Schedule :=
99 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb5[] -> [0, 0, 0] };
100 ; NONAFFINE-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
101 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb5[] -> MemRef_tmp7[] };
102 ; NONAFFINE-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
103 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb5[] -> MemRef_tmp8[] };
104 ; NONAFFINE-NEXT: Stmt_bb17
105 ; NONAFFINE-NEXT: Domain :=
106 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] : 0 <= i0 < tmp9 and 0 <= i1 < tmp14 };
107 ; NONAFFINE-NEXT: Schedule :=
108 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] -> [1, i0, i1] };
109 ; NONAFFINE-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
110 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] -> MemRef_tmp7[] };
111 ; NONAFFINE-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
112 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] -> MemRef_tmp8[] };
113 ; NONAFFINE-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
114 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] -> MemRef_arg4[o0] };
115 ; NONAFFINE-NEXT: MayWriteAccess := [Reduction Type: NONE] [Scalar: 0]
116 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] -> MemRef_arg4[o0] };
119 target datalayout = "e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-f128:128:128-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
121 define void @ham(ptr noalias %arg, ptr noalias %arg1, ptr noalias %arg2, ptr noalias %arg3, ptr noalias %arg4) gc "dummy" {
126 %tmp = load i64, ptr %arg1, align 8
127 %tmp6 = icmp slt i64 %tmp, 0
128 %tmp7 = select i1 %tmp6, i64 0, i64 %tmp
129 %tmp8 = xor i64 %tmp7, -1
130 %tmp9 = load i64, ptr %arg, align 8
131 %tmp10 = icmp sgt i64 %tmp9, 0
132 br i1 %tmp10, label %bb11, label %bb32
137 bb12: ; preds = %bb28, %bb11
138 %tmp13 = phi i64 [ %tmp30, %bb28 ], [ 1, %bb11 ]
139 %tmp14 = load i64, ptr %arg1, align 8
140 %tmp15 = icmp sgt i64 %tmp14, 0
141 br i1 %tmp15, label %bb16, label %bb28
143 bb16: ; preds = %bb12
146 bb17: ; preds = %bb17, %bb16
147 %tmp18 = phi i64 [ %tmp26, %bb17 ], [ 1, %bb16 ]
148 %tmp19 = mul i64 %tmp13, %tmp7
149 %tmp20 = add i64 %tmp19, %tmp8
150 %tmp21 = add i64 %tmp20, %tmp18
151 %tmp22 = add i64 %tmp18, %tmp13
152 %tmp23 = sitofp i64 %tmp22 to double
153 %tmp24 = getelementptr [1000 x double], ptr %arg4, i64 0, i64 %tmp21
154 %dummy = call ptr @llvm.gcread(ptr %tmp24, ptr null)
155 store double %tmp23, ptr %tmp24, align 8
156 %tmp25 = icmp eq i64 %tmp18, %tmp14
157 %tmp26 = add i64 %tmp18, 1
158 br i1 %tmp25, label %bb27, label %bb17
160 bb27: ; preds = %bb17
163 bb28: ; preds = %bb27, %bb12
164 %tmp29 = icmp eq i64 %tmp13, %tmp9
165 %tmp30 = add i64 %tmp13, 1
166 br i1 %tmp29, label %bb31, label %bb12
168 bb31: ; preds = %bb28
171 bb32: ; preds = %bb31, %bb5
175 declare ptr @llvm.gcread(ptr, ptr)