[PM/AA] Rebuild LLVM's alias analysis infrastructure in a way compatible
[oota-llvm.git] / test / Analysis / TypeBasedAliasAnalysis / precedence.ll
1 ; RUN: opt -tbaa -disable-basicaa -gvn -instcombine -S < %s | FileCheck %s --check-prefix=TBAA
2 ; RUN: opt -tbaa -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
8 target 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
16 define i32 @trouble(i32* %x) nounwind {
17 entry:
18   store i32 0, i32* %x, !tbaa !0
19   %0 = bitcast i32* %x to float*
20   store float 0x4002666660000000, float* %0, !tbaa !3
21   %tmp3 = load i32, i32* %x, !tbaa !0
22   ret i32 %tmp3
23 }
24
25 ; Test for PartialAlias aliasing. GVN doesn't yet eliminate the load
26 ; in the BasicAA case.
27
28 ; TBAA:    @offset
29 ; TBAA:      ret i64 0
30 ; BASICAA: @offset
31 ; BASICAA:   ret i64 %tmp3
32 define i64 @offset(i64* %x) nounwind {
33 entry:
34   store i64 0, i64* %x, !tbaa !4
35   %0 = bitcast i64* %x to i8*
36   %1 = getelementptr i8, i8* %0, i64 1
37   store i8 1, i8* %1, !tbaa !5
38   %tmp3 = load i64, i64* %x, !tbaa !4
39   ret i64 %tmp3
40 }
41
42 !0 = !{!2, !2, i64 0}
43 !1 = !{!"simple"}
44 !2 = !{!"int", !1}
45 !3 = !{!6, !6, i64 0}
46 !4 = !{!7, !7, i64 0}
47 !5 = !{!8, !8, i64 0}
48 !6 = !{!"float", !1}
49 !7 = !{!"long", !1}
50 !8 = !{!"small", !1}