[llvm] 6025663 - [SDAG] propagate FMF from target-specific IR intrinsics
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed May 19 04:52:39 PDT 2021
Author: Sanjay Patel
Date: 2021-05-19T07:50:50-04:00
New Revision: 6025663578cd367b6f1bcba3f42076eee4fce7a2
URL: https://github.com/llvm/llvm-project/commit/6025663578cd367b6f1bcba3f42076eee4fce7a2
DIFF: https://github.com/llvm/llvm-project/commit/6025663578cd367b6f1bcba3f42076eee4fce7a2.diff
LOG: [SDAG] propagate FMF from target-specific IR intrinsics
This is a step towards relying more on node-level FMF rather than function-wide
or target settings.
I think it was just an oversight that we didn't get this path in D87361
or follow-on patches.
The lack of FMF propagation is blocking D90901 from converting tests to IR-level FMF.
We can't do much more than this currently because we also fail to propagate flags
from x86-specific node to generic FMA node. That would be another patch, so the
test just verifies that we can transfer from IR to initial SDAG node.
Differential Revision: https://reviews.llvm.org/D102725
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/test/CodeGen/X86/fmf-propagation.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 4f37f862b175..c69f741d964e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -4803,6 +4803,12 @@ void SelectionDAGBuilder::visitTargetIntrinsic(const CallInst &I,
SDVTList VTs = DAG.getVTList(ValueVTs);
+ // Propagate fast-math-flags from IR to node(s).
+ SDNodeFlags Flags;
+ if (auto *FPMO = dyn_cast<FPMathOperator>(&I))
+ Flags.copyFMF(*FPMO);
+ SelectionDAG::FlagInserter FlagsInserter(DAG, Flags);
+
// Create the node.
SDValue Result;
if (IsTgtIntrinsic) {
diff --git a/llvm/test/CodeGen/X86/fmf-propagation.ll b/llvm/test/CodeGen/X86/fmf-propagation.ll
index 1681cfffcd54..44ce80371266 100644
--- a/llvm/test/CodeGen/X86/fmf-propagation.ll
+++ b/llvm/test/CodeGen/X86/fmf-propagation.ll
@@ -48,8 +48,8 @@ define float @fmf_setcc_canon(float %x, float %y) {
declare <16 x float> @llvm.x86.avx512.vfmadd.ps.512(<16 x float>, <16 x float>, <16 x float>, i32)
; CHECK-LABEL: Initial selection DAG: %bb.0 'fmf_target_intrinsic:'
-; CHECK: v16f32 = llvm.x86.avx512.vfmadd.ps.512 TargetConstant:i64<{{.*}}>
-; CHECK: v16f32 = llvm.x86.avx512.vfmadd.ps.512 TargetConstant:i64<{{.*}}>
+; CHECK: v16f32 = llvm.x86.avx512.vfmadd.ps.512 ninf nsz TargetConstant:i64<{{.*}}>
+; CHECK: v16f32 = llvm.x86.avx512.vfmadd.ps.512 nsz TargetConstant:i64<{{.*}}>
define <16 x float> @fmf_target_intrinsic(<16 x float> %a, <16 x float> %b, <16 x float> %c) nounwind {
%t0 = tail call ninf nsz <16 x float> @llvm.x86.avx512.vfmadd.ps.512(<16 x float> %a, <16 x float> %b, <16 x float> %c, i32 4)
More information about the llvm-commits
mailing list