[PATCH] D71495: [SelectionDAG] Copy FP flags when visiting a binary instruction.

Valentin Churavy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 22 11:31:38 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb0ccff6e56b: [SelectionDAG] Copy FP flags when visiting a binary instruction. (authored by vchuravy).

Changed prior to commit:
  https://reviews.llvm.org/D71495?vs=235014&id=235069#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71495

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/test/CodeGen/X86/fmf-reduction.ll


Index: llvm/test/CodeGen/X86/fmf-reduction.ll
===================================================================
--- llvm/test/CodeGen/X86/fmf-reduction.ll
+++ llvm/test/CodeGen/X86/fmf-reduction.ll
@@ -1,14 +1,13 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc < %s -mtriple=x86_64-- -mattr=fma | FileCheck %s
 
-; FIXME: Propagation of IR FMF should not drop flags when adding the DAG reduction flag.
+; Propagation of IR FMF should not drop flags when adding the DAG reduction flag.
 ; This should include an FMA instruction, not separate FMUL/FADD.
 
 define double @julia_dotf(<4 x double> %x, <4 x double> %y, <4 x double> %z, i1 %t3) {
 ; CHECK-LABEL: julia_dotf:
 ; CHECK:       # %bb.0:
-; CHECK-NEXT:    vmulpd %ymm1, %ymm0, %ymm0
-; CHECK-NEXT:    vaddpd %ymm0, %ymm2, %ymm0
+; CHECK-NEXT:    vfmadd213pd {{.*#+}} ymm0 = (ymm1 * ymm0) + ymm2
 ; CHECK-NEXT:    vextractf128 $1, %ymm0, %xmm1
 ; CHECK-NEXT:    vaddpd %xmm1, %xmm0, %xmm0
 ; CHECK-NEXT:    vpermilpd {{.*#+}} xmm1 = xmm0[1,0]
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3124,6 +3124,13 @@
   if (isVectorReductionOp(&I)) {
     Flags.setVectorReduction(true);
     LLVM_DEBUG(dbgs() << "Detected a reduction operation:" << I << "\n");
+
+    // If no flags are set we will propagate the incoming flags, if any flags
+    // are set, we will intersect them with the incoming flag and so we need to
+    // copy the FMF flags here.
+    if (auto *FPOp = dyn_cast<FPMathOperator>(&I)) {
+      Flags.copyFMF(*FPOp);
+    }
   }
 
   SDValue Op1 = getValue(I.getOperand(0));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71495.235069.patch
Type: text/x-patch
Size: 1797 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191222/7753dad9/attachment.bin>


More information about the llvm-commits mailing list