[llvm] 0b50686 - [Local] Add MD_fpmath to combineMetadataForCSE()
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 3 06:28:08 PDT 2023
Author: Nikita Popov
Date: 2023-04-03T15:27:59+02:00
New Revision: 0b5068695aabdca40eddb686be80ef4ad6abf38e
URL: https://github.com/llvm/llvm-project/commit/0b5068695aabdca40eddb686be80ef4ad6abf38e
DIFF: https://github.com/llvm/llvm-project/commit/0b5068695aabdca40eddb686be80ef4ad6abf38e.diff
LOG: [Local] Add MD_fpmath to combineMetadataForCSE()
This was present in patchReplacementInstruction() but not
combineMetadataForCSE(). combineMetadata() already knows how to
merge these properly.
Added:
Modified:
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/Transforms/SimplifyCFG/hoist-with-metadata.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 3fb0d0c0c0265..7a43ee0a5128a 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 72f9f5b2f6fde..ae8fd821d3122 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}
;.
More information about the llvm-commits
mailing list