[llvm] 00999fb - [SelectionDAGBuilder] Pass fast math flags to most of VP SDNodes.
Yeting Kuo via llvm-commits
llvm-commits at lists.llvm.org
Wed May 18 01:15:53 PDT 2022
Author: Yeting Kuo
Date: 2022-05-18T16:15:47+08:00
New Revision: 00999fb6e14231de14db292510c854e1bf3baded
URL: https://github.com/llvm/llvm-project/commit/00999fb6e14231de14db292510c854e1bf3baded
DIFF: https://github.com/llvm/llvm-project/commit/00999fb6e14231de14db292510c854e1bf3baded.diff
LOG: [SelectionDAGBuilder] Pass fast math flags to most of VP SDNodes.
The patch does not pass math flags to float VPCmpIntrinsics because LLParser
could not identify float VPCmpIntrinsics as FPMathOperators.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D125600
Added:
llvm/test/CodeGen/RISCV/pass-fast-math-flags-sdnode.ll
Modified:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 2e0d050d21b18..bf4e6a6751c35 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -7606,7 +7606,10 @@ void SelectionDAGBuilder::visitVectorPredicationIntrinsic(
switch (Opcode) {
default: {
- SDValue Result = DAG.getNode(Opcode, DL, VTs, OpValues);
+ SDNodeFlags SDFlags;
+ if (auto *FPMO = dyn_cast<FPMathOperator>(&VPIntrin))
+ SDFlags.copyFMF(*FPMO);
+ SDValue Result = DAG.getNode(Opcode, DL, VTs, OpValues, SDFlags);
setValue(&VPIntrin, Result);
break;
}
diff --git a/llvm/test/CodeGen/RISCV/pass-fast-math-flags-sdnode.ll b/llvm/test/CodeGen/RISCV/pass-fast-math-flags-sdnode.ll
new file mode 100644
index 0000000000000..c057aba4f26a1
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/pass-fast-math-flags-sdnode.ll
@@ -0,0 +1,9 @@
+; REQUIRES: asserts
+; RUN: llc < %s -mtriple=riscv64 -mattr=+v -debug-only=isel -o /dev/null 2>&1 | FileCheck %s
+declare <vscale x 1 x double> @llvm.vp.fmul.nxv1f64(<vscale x 1 x double> %x, <vscale x 1 x double> %y, <vscale x 1 x i1> %m, i32 %vl)
+
+define <vscale x 1 x double> @foo(<vscale x 1 x double> %x, <vscale x 1 x double> %y, <vscale x 1 x double> %z, <vscale x 1 x i1> %m, i32 %vl) {
+; CHECK: t14: nxv1f64 = vp_fmul nnan ninf nsz arcp contract afn reassoc t2, t4, t8, t13
+ %1 = call fast <vscale x 1 x double> @llvm.vp.fmul.nxv1f64(<vscale x 1 x double> %x, <vscale x 1 x double> %y, <vscale x 1 x i1> %m, i32 %vl)
+ ret <vscale x 1 x double> %1
+}
More information about the llvm-commits
mailing list