1 ; RUN: opt -passes=newgvn -S < %s | FileCheck %s
3 %struct.t = type { ptr }
5 ; The loaded address and the location of the address itself are not aliased,
6 ; so the second reload is not necessary. Check that it can be eliminated.
10 define void @test1(ptr nocapture readonly %p, i32 %v) #0 {
12 %0 = load ptr, ptr %p, align 4, !tbaa !1
13 store volatile i32 %v, ptr %0, align 4, !tbaa !6
14 %1 = load ptr, ptr %p, align 4, !tbaa !1
15 store volatile i32 %v, ptr %1, align 4, !tbaa !6
19 ; The store via the loaded address may overwrite the address itself.
20 ; Make sure that both loads remain.
25 define void @test2(ptr nocapture readonly %p, i32 %v) #0 {
27 %0 = load ptr, ptr %p, align 4, !tbaa !1
28 store volatile i32 %v, ptr %0, align 4, !tbaa !1
29 %1 = load ptr, ptr %p, align 4, !tbaa !1
30 store volatile i32 %v, ptr %1, align 4, !tbaa !1
34 ; The loads are ordered and non-monotonic. Although they are not aliased to
35 ; the stores, make sure both are preserved.
40 define void @test3(ptr nocapture readonly %p, i32 %v) #0 {
42 %0 = load atomic ptr, ptr %p acquire, align 4, !tbaa !1
43 store volatile i32 %v, ptr %0, align 4, !tbaa !6
44 %1 = load atomic ptr, ptr %p acquire, align 4, !tbaa !1
45 store volatile i32 %v, ptr %1, align 4, !tbaa !6
49 attributes #0 = { norecurse nounwind }
52 !2 = !{!"", !3, i64 0}
53 !3 = !{!"any pointer", !4, i64 0}
54 !4 = !{!"omnipotent char", !5, i64 0}
55 !5 = !{!"Simple C/C++ TBAA"}
57 !7 = !{!"int", !4, i64 0}