1 ; RUN: opt -aa-pipeline=tbaa,basic-aa -passes=gvn -S < %s | FileCheck %s
3 target datalayout = "e-p:64:64:64"
5 ; GVN should ignore the store to p1 to see that the load from p is
10 ; CHECK-NEXT: store i32 0, ptr %q
11 ; CHECK-NEXT: ret void
13 define void @yes(i1 %c, ptr %p, ptr %p1, ptr %q) nounwind {
15 store i32 0, ptr %p, !tbaa !1
16 store i32 1, ptr %p1, !tbaa !2
17 br i1 %c, label %if.else, label %if.then
20 %t = load i32, ptr %p, !tbaa !1
28 ; GVN should ignore the store to p1 to see that the first load from p is
29 ; fully redundant. However, the second load uses a different type. Theoretically
30 ; the other type could be unified with the first type, however for now, GVN
31 ; should just be conservative.
33 ; CHECK: @watch_out_for_type_change
35 ; CHECK: %t = load i32, ptr %p
36 ; CHECK: store i32 %t, ptr %q
39 ; CHECK: %u = load i32, ptr %p
40 ; CHECK: store i32 %u, ptr %q
42 define void @watch_out_for_type_change(i1 %c, ptr %p, ptr %p1, ptr %q) nounwind {
44 store i32 0, ptr %p, !tbaa !1
45 store i32 1, ptr %p1, !tbaa !2
46 br i1 %c, label %if.else, label %if.then
49 %t = load i32, ptr %p, !tbaa !3
54 %u = load i32, ptr %p, !tbaa !4
59 ; As before, but the types are swapped. This time GVN does managed to
60 ; eliminate one of the loads before noticing the type mismatch.
62 ; CHECK: @watch_out_for_another_type_change
64 ; CHECK: store i32 0, ptr %q
67 ; CHECK: %u = load i32, ptr %p
68 ; CHECK: store i32 %u, ptr %q
70 define void @watch_out_for_another_type_change(i1 %c, ptr %p, ptr %p1, ptr %q) nounwind {
72 store i32 0, ptr %p, !tbaa !1
73 store i32 1, ptr %p1, !tbaa !2
74 br i1 %c, label %if.else, label %if.then
77 %t = load i32, ptr %p, !tbaa !4
82 %u = load i32, ptr %p, !tbaa !3
94 !7 = !{!"outer space", !9}
95 !8 = !{!"brick red", !5}
96 !9 = !{!"observable universe"}