1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -aa-pipeline=basic-aa -passes=gvn -S < %s | FileCheck %s
4 ; This test catches an issue in MemoryDependenceAnalysis caching mechanism in presense of TBAA.
5 define i64 @foo(ptr %arg, i1 %arg1, i1 %arg2, i1 %arg3, i32 %arg4) {
8 ; CHECK-NEXT: [[TMP:%.*]] = load atomic ptr addrspace(1), ptr [[ARG:%.*]] unordered, align 8
9 ; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds i64, ptr addrspace(1) [[TMP]], i64 8
10 ; CHECK-NEXT: store atomic i64 0, ptr addrspace(1) [[TMP5]] unordered, align 8
11 ; CHECK-NEXT: br label [[BB6:%.*]]
13 ; CHECK-NEXT: [[TMP7:%.*]] = phi i64 [ 0, [[BB:%.*]] ], [ [[TMP22:%.*]], [[BB19:%.*]] ]
14 ; CHECK-NEXT: br i1 [[ARG1:%.*]], label [[BB19]], label [[BB8:%.*]]
16 ; CHECK-NEXT: [[TMP9:%.*]] = load atomic ptr addrspace(1), ptr [[ARG]] unordered, align 8
17 ; CHECK-NEXT: br i1 [[ARG2:%.*]], label [[BB11:%.*]], label [[BB10:%.*]]
19 ; CHECK-NEXT: br label [[BB15:%.*]]
21 ; CHECK-NEXT: br i1 [[ARG3:%.*]], label [[BB12:%.*]], label [[BB18:%.*]]
23 ; CHECK-NEXT: [[TMP14:%.*]] = getelementptr inbounds i64, ptr addrspace(1) [[TMP9]], i64 8
24 ; CHECK-NEXT: store atomic i64 1, ptr addrspace(1) [[TMP14]] unordered, align 8
25 ; CHECK-NEXT: ret i64 0
27 ; CHECK-NEXT: [[TMP16:%.*]] = phi ptr addrspace(1) [ [[TMP9]], [[BB10]] ], [ [[TMP27:%.*]], [[BB26:%.*]] ]
28 ; CHECK-NEXT: [[TMP17:%.*]] = phi i64 [ [[TMP7]], [[BB10]] ], [ 0, [[BB26]] ]
29 ; CHECK-NEXT: switch i32 [[ARG4:%.*]], label [[BB19]] [
30 ; CHECK-NEXT: i32 0, label [[BB26]]
31 ; CHECK-NEXT: i32 1, label [[BB23:%.*]]
34 ; CHECK-NEXT: br label [[BB19]]
36 ; CHECK-NEXT: [[TMP20:%.*]] = phi ptr addrspace(1) [ [[TMP16]], [[BB15]] ], [ inttoptr (i64 1 to ptr addrspace(1)), [[BB6]] ], [ [[TMP9]], [[BB18]] ]
37 ; CHECK-NEXT: [[TMP21:%.*]] = getelementptr inbounds i64, ptr addrspace(1) [[TMP20]], i64 8
38 ; CHECK-NEXT: [[TMP22]] = load atomic i64, ptr addrspace(1) [[TMP21]] unordered, align 8, !tbaa !0
39 ; CHECK-NEXT: br label [[BB6]]
41 ; CHECK-NEXT: [[TMP24:%.*]] = getelementptr inbounds i64, ptr addrspace(1) [[TMP16]], i64 8
42 ; CHECK-NEXT: [[TMP25:%.*]] = load atomic i64, ptr addrspace(1) [[TMP24]] unordered, align 8
43 ; CHECK-NEXT: call void @baz(i64 [[TMP25]]) #0
44 ; CHECK-NEXT: ret i64 0
46 ; CHECK-NEXT: call void @bar()
47 ; CHECK-NEXT: [[TMP27]] = load atomic ptr addrspace(1), ptr [[ARG]] unordered, align 8
48 ; CHECK-NEXT: [[TMP28:%.*]] = getelementptr inbounds i64, ptr addrspace(1) [[TMP27]], i64 8
49 ; CHECK-NEXT: [[TMP29:%.*]] = load atomic i64, ptr addrspace(1) [[TMP28]] unordered, align 8
50 ; CHECK-NEXT: [[TMP30:%.*]] = getelementptr inbounds i64, ptr addrspace(1) [[TMP27]], i64 40
51 ; CHECK-NEXT: store atomic i64 [[TMP29]], ptr addrspace(1) [[TMP30]] unordered, align 4
52 ; CHECK-NEXT: br label [[BB15]]
55 %tmp = load atomic ptr addrspace(1), ptr %arg unordered, align 8
56 %tmp5 = getelementptr inbounds i64, ptr addrspace(1) %tmp, i64 8
57 store atomic i64 0, ptr addrspace(1) %tmp5 unordered, align 8
60 bb6: ; preds = %bb19, %bb
61 %tmp7 = phi i64 [ 0, %bb ], [ %tmp22, %bb19 ]
62 %tmp111 = inttoptr i64 1 to ptr addrspace(1)
63 br i1 %arg1, label %bb19, label %bb8
66 %tmp9 = load atomic ptr addrspace(1), ptr %arg unordered, align 8
67 br i1 %arg2, label %bb11, label %bb10
73 br i1 %arg3, label %bb12, label %bb18
76 %tmp13 = phi ptr addrspace(1) [ %tmp9, %bb11 ]
77 %tmp14 = getelementptr inbounds i64, ptr addrspace(1) %tmp13, i64 8
78 store atomic i64 1, ptr addrspace(1) %tmp14 unordered, align 8
81 bb15: ; preds = %bb26, %bb10
82 %tmp16 = phi ptr addrspace(1) [ %tmp9, %bb10 ], [ %tmp27, %bb26 ]
83 %tmp17 = phi i64 [ %tmp7, %bb10 ], [ 0, %bb26 ]
84 switch i32 %arg4, label %bb19 [
92 bb19: ; preds = %bb18, %bb15, %bb6
93 %tmp20 = phi ptr addrspace(1) [ %tmp16, %bb15 ], [ %tmp111, %bb6 ], [ %tmp9, %bb18 ]
94 %tmp21 = getelementptr inbounds i64, ptr addrspace(1) %tmp20, i64 8
95 %tmp22 = load atomic i64, ptr addrspace(1) %tmp21 unordered, align 8, !tbaa !0
99 %tmp24 = getelementptr inbounds i64, ptr addrspace(1) %tmp16, i64 8
100 %tmp25 = load atomic i64, ptr addrspace(1) %tmp24 unordered, align 8
101 call void @baz(i64 %tmp25) #0
104 bb26: ; preds = %bb15
106 %tmp27 = load atomic ptr addrspace(1), ptr %arg unordered, align 8
107 %tmp28 = getelementptr inbounds i64, ptr addrspace(1) %tmp27, i64 8
108 %tmp29 = load atomic i64, ptr addrspace(1) %tmp28 unordered, align 8
109 %tmp30 = getelementptr inbounds i64, ptr addrspace(1) %tmp27, i64 40
110 store atomic i64 %tmp29, ptr addrspace(1) %tmp30 unordered, align 4
116 ; Function Attrs: inaccessiblememonly readonly
117 declare void @baz(i64) #0
119 attributes #0 = { inaccessiblememonly readonly }
121 !0 = !{!1, !2, i64 8}
122 !1 = !{!"Name", !2, i64 8}
123 !2 = !{!"tbaa_local_fields", !3, i64 0}
124 !3 = !{!"tbaa-access-type"}