[InstCombine] Properly combine metadata when replacing a load with another
[oota-llvm.git] / test / Transforms / InstCombine / load-combine-metadata.ll
1 ; RUN: opt -instcombine -S < %s | FileCheck %s
2
3 target datalayout = "e-m:e-p:64:64:64-i64:64-f80:128-n8:16:32:64-S128"
4
5 ; CHECK-LABEL: @test_load_load_combine_metadata(
6 ; Check that range metadata is combined and AA metadata is preserved
7 ; CHECK: %[[V:.*]] = load i32, i32* %0
8 ; CHECK-SAME: !tbaa !{{[0-9]+}}
9 ; CHECK-SAME: !range ![[RANGE:[0-9]+]]
10 ; CHECK-SAME: !alias.scope !{{[0-9]+}}
11 ; CHECK-SAME: !noalias !{{[0-9]+}}
12 ; CHECK: store i32 %[[V]], i32* %1
13 ; CHECK: store i32 %[[V]], i32* %2
14 define void @test_load_load_combine_metadata(i32*, i32*, i32*) {
15   %a = load i32, i32* %0, !tbaa !8, !range !0, !alias.scope !5, !noalias !6
16   %b = load i32, i32* %0, !range !1
17   store i32 %a, i32* %1
18   store i32 %b, i32* %2
19   ret void
20 }
21
22 ; CHECK: ![[RANGE]] = !{i32 0, i32 1, i32 8, i32 9}
23 !0 = !{ i32 0, i32 1 }
24 !1 = !{ i32 8, i32 9 }
25 !2 = !{!2}
26 !3 = !{!3, !2}
27 !4 = !{!4, !2}
28 !5 = !{!3}
29 !6 = !{!4}
30 !7 = !{ !"tbaa root" }
31 !8 = !{ !7, !7, i64 0 }