From 0b5068695aabdca40eddb686be80ef4ad6abf38e Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 3 Apr 2023 15:26:51 +0200 Subject: [PATCH] [Local] Add MD_fpmath to combineMetadataForCSE() This was present in patchReplacementInstruction() but not combineMetadataForCSE(). combineMetadata() already knows how to merge these properly. --- llvm/lib/Transforms/Utils/Local.cpp | 24 ++++++++++++++-------- .../Transforms/SimplifyCFG/hoist-with-metadata.ll | 19 +++++++++++++++++ 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 3fb0d0c..7a43ee0 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -2729,15 +2729,21 @@ void llvm::combineMetadata(Instruction *K, const Instruction *J, void llvm::combineMetadataForCSE(Instruction *K, const Instruction *J, bool KDominatesJ) { - unsigned KnownIDs[] = { - LLVMContext::MD_tbaa, LLVMContext::MD_alias_scope, - LLVMContext::MD_noalias, LLVMContext::MD_range, - LLVMContext::MD_invariant_load, LLVMContext::MD_nonnull, - LLVMContext::MD_invariant_group, LLVMContext::MD_align, - LLVMContext::MD_dereferenceable, - LLVMContext::MD_dereferenceable_or_null, - LLVMContext::MD_access_group, LLVMContext::MD_preserve_access_index, - LLVMContext::MD_nontemporal, LLVMContext::MD_noundef}; + unsigned KnownIDs[] = {LLVMContext::MD_tbaa, + LLVMContext::MD_alias_scope, + LLVMContext::MD_noalias, + LLVMContext::MD_range, + LLVMContext::MD_fpmath, + LLVMContext::MD_invariant_load, + LLVMContext::MD_nonnull, + LLVMContext::MD_invariant_group, + LLVMContext::MD_align, + LLVMContext::MD_dereferenceable, + LLVMContext::MD_dereferenceable_or_null, + LLVMContext::MD_access_group, + LLVMContext::MD_preserve_access_index, + LLVMContext::MD_nontemporal, + LLVMContext::MD_noundef}; 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 72f9f5b..ae8fd82 100644 --- a/llvm/test/Transforms/SimplifyCFG/hoist-with-metadata.ll +++ b/llvm/test/Transforms/SimplifyCFG/hoist-with-metadata.ll @@ -119,10 +119,29 @@ join: ret ptr %phi } +define void @hoist_fpmath(i1 %c, double %x) { +; CHECK-LABEL: @hoist_fpmath( +; CHECK-NEXT: if: +; CHECK-NEXT: [[T:%.*]] = fadd double [[X:%.*]], 1.000000e+00, !fpmath !2 +; CHECK-NEXT: ret void +; +if: + br i1 %c, label %then, label %else +then: + %t = fadd double %x, 1.0, !fpmath !{ float 2.5 } + br label %out +else: + %e = fadd double %x, 1.0, !fpmath !{ float 5.0 } + br label %out +out: + ret void +} + !0 = !{ i8 0, i8 1 } !1 = !{ i8 3, i8 5 } !2 = !{} ;. ; CHECK: [[RNG0]] = !{i8 0, i8 1, i8 3, i8 5} ; CHECK: [[META1:![0-9]+]] = !{} +; CHECK: [[META2:![0-9]+]] = !{float 2.500000e+00} ;. -- 2.7.4