1 ; RUN: opt < %s -tbaa -basicaa -dse -S | FileCheck %s 2 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 3 4 ; DSE should make use of TBAA. 5 6 ; CHECK: @test0_yes 7 ; CHECK-NEXT: load i8, i8* %b 8 ; CHECK-NEXT: store i8 1, i8* %a 9 ; CHECK-NEXT: ret i8 %y 10 define i8 @test0_yes(i8* %a, i8* %b) nounwind { 11 store i8 0, i8* %a, !tbaa !1 12 %y = load i8, i8* %b, !tbaa !2 13 store i8 1, i8* %a, !tbaa !1 14 ret i8 %y 15 } 16 17 ; CHECK: @test0_no 18 ; CHECK-NEXT: store i8 0, i8* %a 19 ; CHECK-NEXT: load i8, i8* %b 20 ; CHECK-NEXT: store i8 1, i8* %a 21 ; CHECK-NEXT: ret i8 %y 22 define i8 @test0_no(i8* %a, i8* %b) nounwind { 23 store i8 0, i8* %a, !tbaa !3 24 %y = load i8, i8* %b, !tbaa !4 25 store i8 1, i8* %a, !tbaa !3 26 ret i8 %y 27 } 28 29 ; CHECK: @test1_yes 30 ; CHECK-NEXT: load i8, i8* %b 31 ; CHECK-NEXT: store i8 1, i8* %a 32 ; CHECK-NEXT: ret i8 %y 33 define i8 @test1_yes(i8* %a, i8* %b) nounwind { 34 store i8 0, i8* %a 35 %y = load i8, i8* %b, !tbaa !5 36 store i8 1, i8* %a 37 ret i8 %y 38 } 39 40 ; CHECK: @test1_no 41 ; CHECK-NEXT: store i8 0, i8* %a 42 ; CHECK-NEXT: load i8, i8* %b 43 ; CHECK-NEXT: store i8 1, i8* %a 44 ; CHECK-NEXT: ret i8 %y 45 define i8 @test1_no(i8* %a, i8* %b) nounwind { 46 store i8 0, i8* %a 47 %y = load i8, i8* %b, !tbaa !6 48 store i8 1, i8* %a 49 ret i8 %y 50 } 51 52 ; Root note. 53 !0 = !{ } 54 ; Some type. 55 !1 = !{!7, !7, i64 0} 56 ; Some other non-aliasing type. 57 !2 = !{!8, !8, i64 0} 58 59 ; Some type. 60 !3 = !{!9, !9, i64 0} 61 ; Some type in a different type system. 62 !4 = !{!10, !10, i64 0} 63 64 ; Invariant memory. 65 !5 = !{!11, !11, i64 0, i1 1} 66 ; Not invariant memory. 67 !6 = !{!11, !11, i64 0, i1 0} 68 !7 = !{ !"foo", !0 } 69 !8 = !{ !"bar", !0 } 70 !9 = !{ !"foo", !0 } 71 !10 = !{ !"bar", !"different" } 72 !11 = !{ !"qux", !0} 73