[PATCH] D125600: [SelectionDAGBuilder] Pass fast math flags to most of VP SDNodes.

Yeting Kuo via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 16 07:27:48 PDT 2022


fakepaper56 updated this revision to Diff 429712.
fakepaper56 added a comment.

After fixing getNode, pass SDNodeFlags to getNode of SDVTList version.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125600/new/

https://reviews.llvm.org/D125600

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/test/CodeGen/RISCV/pass-fast-math-flags-sdnode.ll


Index: llvm/test/CodeGen/RISCV/pass-fast-math-flags-sdnode.ll
===================================================================
--- /dev/null
+++ 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
+}
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -7606,7 +7606,10 @@
 
   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;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125600.429712.patch
Type: text/x-patch
Size: 1520 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220516/114186b1/attachment.bin>


More information about the llvm-commits mailing list