Skip to content

Commit 358e765

Browse files
brunodf-snpsnikic
authored andcommitted
[LICM] Add test show missed promotion due to AAInfo merging (NFC)
1 parent d293a35 commit 358e765

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2+
; RUN: opt < %s -S -passes=licm | FileCheck %s
3+
4+
; See https://discourse.llvm.org/t/rfc-dont-merge-memory-locations-in-aliassettracker/73336
5+
; pairwise TBAA indicates NoAlias of load/store ptr at %s with store i32 at %0
6+
; yet LICM fails to promote load/store ptr %s out of the loop
7+
8+
define void @_Z4testP1S(ptr %s) {
9+
; CHECK-LABEL: define void @_Z4testP1S(
10+
; CHECK-SAME: ptr [[S:%.*]]) {
11+
; CHECK-NEXT: entry:
12+
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
13+
; CHECK: for.cond.cleanup:
14+
; CHECK-NEXT: ret void
15+
; CHECK: for.body:
16+
; CHECK-NEXT: [[I_05:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FOR_BODY]] ]
17+
; CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[S]], align 4, !tbaa [[TBAA0:![0-9]+]]
18+
; CHECK-NEXT: store i32 [[I_05]], ptr [[TMP0]], align 4, !tbaa [[TBAA5:![0-9]+]]
19+
; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i32 1
20+
; CHECK-NEXT: store ptr [[ADD_PTR_I]], ptr [[S]], align 4, !tbaa [[TBAA7:![0-9]+]]
21+
; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_05]], 1
22+
; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i32 [[INC]], 100
23+
; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY]]
24+
;
25+
entry:
26+
br label %for.body
27+
28+
for.cond.cleanup: ; preds = %for.body
29+
ret void
30+
31+
for.body: ; preds = %entry, %for.body
32+
%i.05 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
33+
%0 = load ptr, ptr %s, align 4, !tbaa !0
34+
store i32 %i.05, ptr %0, align 4, !tbaa !5
35+
%add.ptr.i = getelementptr inbounds i32, ptr %0, i32 1
36+
store ptr %add.ptr.i, ptr %s, align 4, !tbaa !7
37+
%inc = add nuw nsw i32 %i.05, 1
38+
%exitcond.not = icmp eq i32 %inc, 100
39+
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
40+
}
41+
42+
!0 = !{!1, !2, i64 0}
43+
!1 = !{!"_ZTS1S", !2, i64 0}
44+
!2 = !{!"any pointer", !3, i64 0}
45+
!3 = !{!"omnipotent char", !4, i64 0}
46+
!4 = !{!"Simple C++ TBAA"}
47+
!5 = !{!6, !6, i64 0}
48+
!6 = !{!"int", !3, i64 0}
49+
!7 = !{!2, !2, i64 0}
50+
;.
51+
; CHECK: [[TBAA0]] = !{[[META1:![0-9]+]], [[META2:![0-9]+]], i64 0}
52+
; CHECK: [[META1]] = !{!"_ZTS1S", [[META2]], i64 0}
53+
; CHECK: [[META2]] = !{!"any pointer", [[META3:![0-9]+]], i64 0}
54+
; CHECK: [[META3]] = !{!"omnipotent char", [[META4:![0-9]+]], i64 0}
55+
; CHECK: [[META4]] = !{!"Simple C++ TBAA"}
56+
; CHECK: [[TBAA5]] = !{[[META6:![0-9]+]], [[META6]], i64 0}
57+
; CHECK: [[META6]] = !{!"int", [[META3]], i64 0}
58+
; CHECK: [[TBAA7]] = !{[[META2]], [[META2]], i64 0}
59+
;.

0 commit comments

Comments
 (0)