https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/103938
>From 0f1cd91266f2665a75fba619f97b770a42676509 Mon Sep 17 00:00:00 2001 From: Matt Arsenault <matthew.arsena...@amd.com> Date: Wed, 14 Aug 2024 16:19:30 +0400 Subject: [PATCH] Local: Handle noalias_addrspace in combineMetadata This should act like range. --- llvm/lib/Transforms/Utils/Local.cpp | 7 ++++++- llvm/test/Transforms/SimplifyCFG/hoist-with-metadata.ll | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 725b512fb86e76..897a347b01a670 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -3361,6 +3361,10 @@ void llvm::combineMetadata(Instruction *K, const Instruction *J, if (DoesKMove) K->setMetadata(Kind, MDNode::getMergedProfMetadata(KMD, JMD, K, J)); break; + case LLVMContext::MD_noalias_addrspace: + if (DoesKMove) + K->setMetadata(Kind, MDNode::getMostGenericRange(JMD, KMD)); + break; } } // Set !invariant.group from J if J has it. If both instructions have it @@ -3402,7 +3406,8 @@ void llvm::combineMetadataForCSE(Instruction *K, const Instruction *J, LLVMContext::MD_prof, LLVMContext::MD_nontemporal, LLVMContext::MD_noundef, - LLVMContext::MD_mmra}; + LLVMContext::MD_mmra, + LLVMContext::MD_noalias_addrspace}; combineMetadata(K, J, KnownIDs, KDominatesJ); } diff --git a/llvm/test/Transforms/SimplifyCFG/hoist-with-metadata.ll b/llvm/test/Transforms/SimplifyCFG/hoist-with-metadata.ll index 18aa5c9e044a98..f8985e78c0ca57 100644 --- a/llvm/test/Transforms/SimplifyCFG/hoist-with-metadata.ll +++ b/llvm/test/Transforms/SimplifyCFG/hoist-with-metadata.ll @@ -319,7 +319,7 @@ out: define void @hoist_noalias_addrspace_both(i1 %c, ptr %p, i64 %val) { ; CHECK-LABEL: @hoist_noalias_addrspace_both( ; CHECK-NEXT: if: -; CHECK-NEXT: [[T:%.*]] = atomicrmw add ptr [[P:%.*]], i64 [[VAL:%.*]] seq_cst, align 8 +; CHECK-NEXT: [[T:%.*]] = atomicrmw add ptr [[P:%.*]], i64 [[VAL:%.*]] seq_cst, align 8, !noalias.addrspace [[META7:![0-9]+]] ; CHECK-NEXT: ret void ; if: @@ -361,7 +361,7 @@ out: define void @hoist_noalias_addrspace_switch(i64 %i, ptr %p, i64 %val) { ; CHECK-LABEL: @hoist_noalias_addrspace_switch( ; CHECK-NEXT: out: -; CHECK-NEXT: [[T:%.*]] = atomicrmw add ptr [[P:%.*]], i64 [[VAL:%.*]] seq_cst, align 8 +; CHECK-NEXT: [[T:%.*]] = atomicrmw add ptr [[P:%.*]], i64 [[VAL:%.*]] seq_cst, align 8, !noalias.addrspace [[META8:![0-9]+]] ; CHECK-NEXT: ret void ; switch i64 %i, label %bb0 [ @@ -398,4 +398,6 @@ out: ; CHECK: [[RNG4]] = !{i32 0, i32 10} ; CHECK: [[META5]] = !{i64 4} ; CHECK: [[META6]] = !{float 2.500000e+00} +; CHECK: [[META7]] = !{i32 5, i32 6} +; CHECK: [[META8]] = !{i32 4, i32 8} ;. _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits