1 ; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-print-scops -polly-allow-modref-calls \
2 ; RUN: -polly-invariant-load-hoisting=true \
3 ; RUN: -disable-output < %s | FileCheck %s
4 ; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-print-scops -polly-allow-nonaffine \
5 ; RUN: -polly-invariant-load-hoisting=true \
6 ; RUN: -polly-allow-modref-calls -disable-output < %s | 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: double 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: double 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: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
53 ; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb17[i0] -> MemRef_arg4[p_1 + i0] };
54 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
55 ; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb17[i0] -> MemRef_arg1[o0] };
56 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
57 ; CHECK-NEXT: [tmp14, p_1] -> { Stmt_bb17[i0] -> MemRef_arg4[o0] };
61 ; NONAFFINE: Function: ham
62 ; NONAFFINE-NEXT: Region: %bb5---%bb32
63 ; NONAFFINE-NEXT: Max Loop Depth: 2
64 ; NONAFFINE-NEXT: Invariant Accesses: {
65 ; NONAFFINE-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
66 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb5[] -> MemRef_arg[0] };
67 ; NONAFFINE-NEXT: Execution Context: [tmp9, tmp14] -> { : }
68 ; NONAFFINE-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
69 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb12[i0] -> MemRef_arg1[0] };
70 ; NONAFFINE-NEXT: Execution Context: [tmp9, tmp14] -> { : }
72 ; NONAFFINE-NEXT: Context:
73 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { : -9223372036854775808 <= tmp9 <= 9223372036854775807 and -9223372036854775808 <= tmp14 <= 9223372036854775807 }
74 ; NONAFFINE-NEXT: Assumed Context:
75 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { : }
76 ; NONAFFINE-NEXT: Invalid Context:
77 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { : false }
78 ; NONAFFINE: p0: %tmp9
79 ; NONAFFINE-NEXT: p1: %tmp14
80 ; NONAFFINE-NEXT: Arrays {
81 ; NONAFFINE-NEXT: i64 MemRef_arg[*]; // Element size 8
82 ; NONAFFINE-NEXT: i64 MemRef_arg1[*]; // Element size 8
83 ; NONAFFINE-NEXT: i64 MemRef_tmp7; // Element size 8
84 ; NONAFFINE-NEXT: i64 MemRef_tmp8; // Element size 8
85 ; NONAFFINE-NEXT: double MemRef_arg4[*]; // Element size 8
87 ; NONAFFINE-NEXT: Arrays (Bounds as pw_affs) {
88 ; NONAFFINE-NEXT: i64 MemRef_arg[*]; // Element size 8
89 ; NONAFFINE-NEXT: i64 MemRef_arg1[*]; // Element size 8
90 ; NONAFFINE-NEXT: i64 MemRef_tmp7; // Element size 8
91 ; NONAFFINE-NEXT: i64 MemRef_tmp8; // Element size 8
92 ; NONAFFINE-NEXT: double MemRef_arg4[*]; // Element size 8
94 ; NONAFFINE-NEXT: Alias Groups (0):
96 ; NONAFFINE-NEXT: Statements {
97 ; NONAFFINE-NEXT: Stmt_bb5
98 ; NONAFFINE-NEXT: Domain :=
99 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb5[] };
100 ; NONAFFINE-NEXT: Schedule :=
101 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb5[] -> [0, 0, 0] };
102 ; NONAFFINE-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
103 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb5[] -> MemRef_tmp7[] };
104 ; NONAFFINE-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
105 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb5[] -> MemRef_tmp8[] };
106 ; NONAFFINE-NEXT: Stmt_bb17
107 ; NONAFFINE-NEXT: Domain :=
108 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] : 0 <= i0 < tmp9 and 0 <= i1 < tmp14 };
109 ; NONAFFINE-NEXT: Schedule :=
110 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] -> [1, i0, i1] };
111 ; NONAFFINE-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
112 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] -> MemRef_tmp7[] };
113 ; NONAFFINE-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
114 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] -> MemRef_tmp8[] };
115 ; NONAFFINE-NEXT: MayWriteAccess := [Reduction Type: NONE] [Scalar: 0]
116 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] -> MemRef_arg4[o0] };
117 ; NONAFFINE-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
118 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] -> MemRef_arg[o0] };
119 ; NONAFFINE-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
120 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] -> MemRef_arg1[o0] };
121 ; NONAFFINE-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
122 ; NONAFFINE-NEXT: [tmp9, tmp14] -> { Stmt_bb17[i0, i1] -> MemRef_arg4[o0] };
124 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"
126 define void @ham(ptr noalias %arg, ptr noalias %arg1, ptr noalias %arg2, ptr noalias %arg3, ptr noalias %arg4) unnamed_addr {
131 %tmp = load i64, ptr %arg1, align 8
132 %tmp6 = icmp slt i64 %tmp, 0
133 %tmp7 = select i1 %tmp6, i64 0, i64 %tmp
134 %tmp8 = xor i64 %tmp7, -1
135 %tmp9 = load i64, ptr %arg, align 8
136 %tmp10 = icmp sgt i64 %tmp9, 0
137 br i1 %tmp10, label %bb11, label %bb32
142 bb12: ; preds = %bb28, %bb11
143 %tmp13 = phi i64 [ %tmp30, %bb28 ], [ 1, %bb11 ]
144 %tmp14 = load i64, ptr %arg1, align 8
145 %tmp15 = icmp sgt i64 %tmp14, 0
146 br i1 %tmp15, label %bb16, label %bb28
148 bb16: ; preds = %bb12
151 bb17: ; preds = %bb17, %bb16
152 %tmp18 = phi i64 [ %tmp26, %bb17 ], [ 1, %bb16 ]
153 %tmp19 = mul i64 %tmp13, %tmp7
154 %tmp20 = add i64 %tmp19, %tmp8
155 %tmp21 = add i64 %tmp20, %tmp18
156 %tmp22 = add i64 %tmp18, %tmp13
157 %tmp23 = sitofp i64 %tmp22 to double
158 %tmp24 = getelementptr [1000 x double], ptr %arg4, i64 0, i64 %tmp21
159 %call = call double @func(ptr %tmp24) #2
160 %sum = fadd double %call, %tmp23
161 store double %sum, ptr %tmp24, align 8
162 %tmp25 = icmp eq i64 %tmp18, %tmp14
163 %tmp26 = add i64 %tmp18, 1
164 br i1 %tmp25, label %bb27, label %bb17
166 bb27: ; preds = %bb17
169 bb28: ; preds = %bb27, %bb12
170 %tmp29 = icmp eq i64 %tmp13, %tmp9
171 %tmp30 = add i64 %tmp13, 1
172 br i1 %tmp29, label %bb31, label %bb12
174 bb31: ; preds = %bb28
177 bb32: ; preds = %bb31, %bb5
181 declare double @func(ptr) #1
183 attributes #1 = { nounwind readonly }