xref: /llvm-project/llvm/test/Analysis/TypeBasedAliasAnalysis/precedence.ll (revision 6402fc22e1bccd0984beadfe931511175bac688c)
1; RUN: opt -aa-pipeline=tbaa -passes=gvn,instcombine -S < %s | FileCheck %s --check-prefix=TBAA
2; RUN: opt -aa-pipeline=basic-aa,tbaa -passes=gvn,instcombine -S < %s | FileCheck %s --check-prefix=BASICAA
3
4; According to the TBAA metadata the load and store don't alias. However,
5; according to the actual code, they do. Disabling basicaa shows the raw TBAA
6; results.
7
8target datalayout = "e-p:64:64:64"
9
10; Test for simple MustAlias aliasing.
11
12; TBAA:    @trouble
13; TBAA:      ret i32 0
14; BASICAA: @trouble
15; BASICAA:   ret i32 1075000115
16define i32 @trouble(ptr %x) nounwind {
17entry:
18  store i32 0, ptr %x, !tbaa !0
19  store float 0x4002666660000000, ptr %x, !tbaa !3
20  %tmp3 = load i32, ptr %x, !tbaa !0
21  ret i32 %tmp3
22}
23
24; Test for PartialAlias aliasing. GVN doesn't yet eliminate the load
25; in the BasicAA case.
26
27; TBAA:    @offset
28; TBAA:      ret i64 0
29; BASICAA: @offset
30; BASICAA:   ret i64 %tmp3
31define i64 @offset(ptr %x) nounwind {
32entry:
33  store i64 0, ptr %x, !tbaa !4
34  %0 = getelementptr i8, ptr %x, i64 1
35  store i8 1, ptr %0, !tbaa !5
36  %tmp3 = load i64, ptr %x, !tbaa !4
37  ret i64 %tmp3
38}
39
40!0 = !{!2, !2, i64 0}
41!1 = !{!"simple"}
42!2 = !{!"int", !1}
43!3 = !{!6, !6, i64 0}
44!4 = !{!7, !7, i64 0}
45!5 = !{!8, !8, i64 0}
46!6 = !{!"float", !1}
47!7 = !{!"long", !1}
48!8 = !{!"small", !1}
49