blob: 1aed1e6df857a571b55b7746dd34a1addbfa1eef [file] [log] [blame]
Michael Kruse05351372018-12-20 21:24:54 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s
2
3// Verify that the outer loop has the llvm.access.group property for the
4// accesses outside and inside the inner loop, even when the inner loop
5// is not perfectly nested.
6void vectorize_imperfectly_nested_test(int *List, int Length) {
7#pragma clang loop vectorize(assume_safety) interleave(disable) unroll(disable)
8 for (int i = 0; i < Length; ++i) {
9 List[i * Length] = 42;
10#pragma clang loop vectorize(assume_safety) interleave(disable) unroll(disable)
11 for (int j = 1; j < Length - 1; ++j)
12 List[i * Length + j] = (i + j) * 2;
13 List[(i + 1) * Length - 1] = 21;
14 }
15}
16
17
18// CHECK: load i32, i32* %Length.addr, align 4, !llvm.access.group ![[ACCESS_GROUP_2:[0-9]+]]
19
20// CHECK: %[[MUL:.+]] = mul nsw i32 %add, 2
21// CHECK: store i32 %[[MUL]], i32* %{{.+}}, !llvm.access.group ![[ACCESS_GROUP_3:[0-9]+]]
22// CHECK: br label %{{.+}}, !llvm.loop ![[INNER_LOOPID:[0-9]+]]
23// CHECK: store i32 21, i32* %{{.+}}, !llvm.access.group ![[ACCESS_GROUP_2]]
24// CHECK: br label %{{.+}}, !llvm.loop ![[OUTER_LOOPID:[0-9]+]]
25
26// CHECK: ![[ACCESS_GROUP_2]] = distinct !{}
27// CHECK: ![[ACCESS_GROUP_LIST_3:[0-9]+]] = !{![[ACCESS_GROUP_2]], ![[ACCESS_GROUP_4:[0-9]+]]}
28// CHECK: ![[ACCESS_GROUP_4]] = distinct !{}
Michael Kruse58e76422019-04-01 17:47:41 +000029// CHECK: ![[INNER_LOOPID]] = distinct !{![[INNER_LOOPID]], ![[PARALLEL_ACCESSES_8:[0-9]+]]
Michael Kruse05351372018-12-20 21:24:54 +000030// CHECK: ![[PARALLEL_ACCESSES_8]] = !{!"llvm.loop.parallel_accesses", ![[ACCESS_GROUP_4]]}
Michael Kruse58e76422019-04-01 17:47:41 +000031// CHECK: ![[OUTER_LOOPID]] = distinct !{![[OUTER_LOOPID]], ![[PARALLEL_ACCESSES_10:[0-9]+]]
Michael Kruse05351372018-12-20 21:24:54 +000032// CHECK: ![[PARALLEL_ACCESSES_10]] = !{!"llvm.loop.parallel_accesses", ![[ACCESS_GROUP_2]]}