Add a basic testcase for TBAA-aware DSE.
[oota-llvm.git] / test / Analysis / TypeBasedAliasAnalysis / dse.ll
1 ; RUN: opt < %s -enable-tbaa -tbaa -basicaa -dse -S | FileCheck %s
2
3 ; DSE should make use of TBAA.
4
5 ; CHECK: @test0_yes
6 ; CHECK-NEXT: load i8* %b
7 ; CHECK-NEXT: store i8 1, i8* %a
8 ; CHECK-NEXT: ret i8 %y
9 define i8 @test0_yes(i8* %a, i8* %b) nounwind {
10   store i8 0, i8* %a, !tbaa !1
11   %y = load i8* %b, !tbaa !2
12   store i8 1, i8* %a, !tbaa !1
13   ret i8 %y
14 }
15
16 ; CHECK: @test0_no
17 ; CHECK-NEXT: store i8 0, i8* %a
18 ; CHECK-NEXT: load i8* %b
19 ; CHECK-NEXT: store i8 1, i8* %a
20 ; CHECK-NEXT: ret i8 %y
21 define i8 @test0_no(i8* %a, i8* %b) nounwind {
22   store i8 0, i8* %a, !tbaa !3
23   %y = load i8* %b, !tbaa !4
24   store i8 1, i8* %a, !tbaa !3
25   ret i8 %y
26 }
27
28 ; Root note.
29 !0 = metadata !{ }
30 ; Some type.
31 !1 = metadata !{ metadata !"foo", metadata !0 }
32 ; Some other non-aliasing type.
33 !2 = metadata !{ metadata !"bar", metadata !0 }
34
35 ; Some type.
36 !3 = metadata !{ metadata !"foo", metadata !0 }
37 ; Some type in a different type system.
38 !4 = metadata !{ metadata !"bar", metadata !"different" }
39
40 ; Invariant memory.
41 !5 = metadata !{ metadata !"qux", metadata !0, i1 1 }
42 ; Not invariant memory.
43 !6 = metadata !{ metadata !"qux", metadata !0, i1 0 }