69 lines · plain
1; RUN: opt -passes=instcombine -S < %s | FileCheck %s2 3@g1 = common global ptr null, align 84 5%struct.S1 = type { i32, float }6%struct.S2 = type { float, i32 }7 8; Check that instcombine preserves metadata when it merges two loads.9;10; CHECK: return:11; CHECK: load ptr, ptr %{{[a-z0-9.]+}}, align 8, !nonnull ![[EMPTYNODE:[0-9]+]]12; CHECK: load i32, ptr %{{[a-z0-9.]+}}, align 4, !tbaa ![[TBAA:[0-9]+]], !range ![[RANGE:[0-9]+]], !invariant.load ![[EMPTYNODE:[0-9]+]], !alias.scope ![[ALIAS_SCOPE:[0-9]+]], !noalias ![[NOALIAS:[0-9]+]]13 14; Function Attrs: nounwind ssp uwtable15define i32 @phi_load_metadata(ptr %s1, ptr %s2, i32 %c, ptr %x0, ptr %x1) #0 {16entry:17 %tobool = icmp eq i32 %c, 018 br i1 %tobool, label %if.end, label %if.then19 20if.then: ; preds = %entry21 %i = getelementptr inbounds %struct.S2, ptr %s2, i64 0, i32 122 %val = load i32, ptr %i, align 4, !tbaa !0, !alias.scope !13, !noalias !14, !invariant.load !17, !range !1823 %p0 = load ptr, ptr %x0, align 8, !nonnull !1724 br label %return25 26if.end: ; preds = %entry27 %val2 = load i32, ptr %s1, align 4, !tbaa !2, !alias.scope !15, !noalias !16, !invariant.load !17, !range !1928 %p1 = load ptr, ptr %x1, align 8, !nonnull !1729 br label %return30 31return: ; preds = %if.end, %if.then32 %retval = phi i32 [ %val, %if.then ], [ %val2, %if.end ]33 %pval = phi ptr [ %p0, %if.then ], [ %p1, %if.end ]34 store ptr %pval, ptr @g1, align 835 ret i32 %retval36}37 38; CHECK: ![[EMPTYNODE]] = !{}39; CHECK: ![[TBAA]] = !{![[TAG1:[0-9]+]], ![[TAG1]], i64 0}40; CHECK: ![[TAG1]] = !{!"int", !{{[0-9]+}}, i64 0}41; CHECK: ![[RANGE]] = !{i32 10, i32 25}42; CHECK: ![[ALIAS_SCOPE]] = !{![[SCOPE0:[0-9]+]], ![[SCOPE1:[0-9]+]], ![[SCOPE2:[0-9]+]]}43; CHECK: ![[SCOPE0]] = distinct !{![[SCOPE0]], !{{[0-9]+}}, !"scope0"}44; CHECK: ![[SCOPE1]] = distinct !{![[SCOPE1]], !{{[0-9]+}}, !"scope1"}45; CHECK: ![[SCOPE2]] = distinct !{![[SCOPE2]], !{{[0-9]+}}, !"scope2"}46; CHECK: ![[NOALIAS]] = !{![[SCOPE3:[0-9]+]]}47; CHECK: ![[SCOPE3]] = distinct !{![[SCOPE3]], !{{[0-9]+}}, !"scope3"}48 49!0 = !{!1, !4, i64 4}50!1 = !{!"", !7, i64 0, !4, i64 4}51!2 = !{!3, !4, i64 0}52!3 = !{!"", !4, i64 0, !7, i64 4}53!4 = !{!"int", !5, i64 0}54!5 = !{!"omnipotent char", !6, i64 0}55!6 = !{!"Simple C/C++ TBAA"}56!7 = !{!"float", !5, i64 0}57!8 = !{!8, !"some domain"}58!9 = !{!9, !8, !"scope0"}59!10 = !{!10, !8, !"scope1"}60!11 = !{!11, !8, !"scope2"}61!12 = !{!12, !8, !"scope3"}62!13 = !{!9, !10}63!14 = !{!11, !12}64!15 = !{!9, !11}65!16 = !{!10, !12}66!17 = !{}67!18 = !{i32 10, i32 20}68!19 = !{i32 15, i32 25}69