Skip to content

Commit 127f486

Browse files
committed
[LV] Add test showing incorrect metadata merging when narrowing IGs.
Add test showing that incorrect tbaa metadata is added to the widened loads and stores when narrowing interleave groups. The widened loads/stores currently have the TBAA metadata of the first load/store, even though the wide accesses also access data with types of the second load/store.
1 parent 8338a3c commit 127f486

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --filter-out-after "^scalar.ph:" --version 5
2+
; RUN: opt -p loop-vectorize -force-vector-width=2 -force-vector-interleave=1 -S %s | FileCheck --check-prefixes=VF2 %s
3+
4+
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
5+
target triple = "arm64-apple-macosx"
6+
7+
; FIXME: Currently the widened load/stores incorrectly use the tbaa metadata
8+
; from the first load/store.
9+
define void @load_store_interleave_group_with_metadata(ptr noalias %data) {
10+
; VF2-LABEL: define void @load_store_interleave_group_with_metadata(
11+
; VF2-SAME: ptr noalias [[DATA:%.*]]) {
12+
; VF2-NEXT: [[ENTRY:.*:]]
13+
; VF2-NEXT: br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]
14+
; VF2: [[VECTOR_PH]]:
15+
; VF2-NEXT: br label %[[VECTOR_BODY:.*]]
16+
; VF2: [[VECTOR_BODY]]:
17+
; VF2-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
18+
; VF2-NEXT: [[TMP0:%.*]] = shl nsw i64 [[INDEX]], 1
19+
; VF2-NEXT: [[TMP1:%.*]] = getelementptr inbounds i64, ptr [[DATA]], i64 [[TMP0]]
20+
; VF2-NEXT: [[WIDE_LOAD:%.*]] = load <2 x i64>, ptr [[TMP1]], align 8, !tbaa [[TBAA0:![0-9]+]]
21+
; VF2-NEXT: store <2 x i64> [[WIDE_LOAD]], ptr [[TMP1]], align 8, !tbaa [[TBAA4:![0-9]+]]
22+
; VF2-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 1
23+
; VF2-NEXT: [[TMP2:%.*]] = icmp eq i64 [[INDEX_NEXT]], 100
24+
; VF2-NEXT: br i1 [[TMP2]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP6:![0-9]+]]
25+
; VF2: [[MIDDLE_BLOCK]]:
26+
; VF2-NEXT: br i1 true, [[EXIT:label %.*]], label %[[SCALAR_PH]]
27+
; VF2: [[SCALAR_PH]]:
28+
;
29+
entry:
30+
br label %loop
31+
32+
loop:
33+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
34+
%mul.2 = shl nsw i64 %iv, 1
35+
%data.0 = getelementptr inbounds i64, ptr %data, i64 %mul.2
36+
%l.0 = load i64, ptr %data.0, align 8, !tbaa !2, !range !4
37+
store i64 %l.0, ptr %data.0, align 8, !tbaa !2
38+
%add.1 = or disjoint i64 %mul.2, 1
39+
%data.1 = getelementptr inbounds i64, ptr %data, i64 %add.1
40+
%l.1 = load i64, ptr %data.1, align 8, !tbaa !3, !range !5
41+
store i64 %l.1, ptr %data.1, align 8, !tbaa !3
42+
%iv.next = add nuw nsw i64 %iv, 1
43+
%ec = icmp eq i64 %iv.next, 100
44+
br i1 %ec, label %exit, label %loop
45+
46+
exit:
47+
ret void
48+
}
49+
50+
!0 = !{!"Simple C/C++ TBAA"}
51+
!1 = !{!"omnipotent char", !0, i64 0}
52+
!2 = !{!"A", !1, i64 0}
53+
!3 = !{!"B", !1, i64 0}
54+
!4 = !{ i64 0, i64 2 }
55+
!5 = !{ i64 0, i64 2 }
56+
57+
;.
58+
; VF2: [[TBAA0]] = !{[[META1:![0-9]+]], [[META1]], i64 0, i64 0}
59+
; VF2: [[META1]] = !{!"A", [[META2:![0-9]+]]}
60+
; VF2: [[META2]] = !{!"omnipotent char", [[META3:![0-9]+]], i64 0}
61+
; VF2: [[META3]] = !{!"Simple C/C++ TBAA"}
62+
; VF2: [[TBAA4]] = !{[[META5:![0-9]+]], [[META5]], i64 0, i64 0}
63+
; VF2: [[META5]] = !{!"B", [[META2]]}
64+
; VF2: [[LOOP6]] = distinct !{[[LOOP6]], [[META7:![0-9]+]], [[META8:![0-9]+]]}
65+
; VF2: [[META7]] = !{!"llvm.loop.isvectorized", i32 1}
66+
; VF2: [[META8]] = !{!"llvm.loop.unroll.runtime.disable"}
67+
;.
68+
; VF4: [[TBAA0]] = !{[[META1:![0-9]+]], [[META1]], i64 0}
69+
; VF4: [[META1]] = !{!"omnipotent char", [[META2:![0-9]+]], i64 0}
70+
; VF4: [[META2]] = !{!"Simple C/C++ TBAA"}
71+
; VF4: [[LOOP3]] = distinct !{[[LOOP3]], [[META4:![0-9]+]], [[META5:![0-9]+]]}
72+
; VF4: [[META4]] = !{!"llvm.loop.isvectorized", i32 1}
73+
; VF4: [[META5]] = !{!"llvm.loop.unroll.runtime.disable"}
74+
;.

0 commit comments

Comments
 (0)