[PATCH] D36706: DAGCombiner: Add form of isFPExtFree to check uses

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 5 09:48:06 PDT 2017


arsenm updated this revision to Diff 117841.
arsenm added a comment.

Also update fsub case


https://reviews.llvm.org/D36706

Files:
  include/llvm/Target/TargetLowering.h
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp


Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -9095,7 +9095,7 @@
   // Always prefer FMAD to FMA for precision.
   unsigned PreferredFusedOpcode = HasFMAD ? ISD::FMAD : ISD::FMA;
   bool Aggressive = TLI.enableAggressiveFMAFusion(VT);
-  bool LookThroughFPExt = TLI.isFPExtFree(VT);
+  bool LookThroughFPExt = TLI.isFPExtFree(PreferredFusedOpcode, VT);
 
   // Is the node an FMUL and contractable either due to global flags or
   // SDNodeFlags.
@@ -9297,7 +9297,7 @@
   // Always prefer FMAD to FMA for precision.
   unsigned PreferredFusedOpcode = HasFMAD ? ISD::FMAD : ISD::FMA;
   bool Aggressive = TLI.enableAggressiveFMAFusion(VT);
-  bool LookThroughFPExt = TLI.isFPExtFree(VT);
+  bool LookThroughFPExt = TLI.isFPExtFree(PreferredFusedOpcode, VT);
 
   // Is the node an FMUL and contractable either due to global flags or
   // SDNodeFlags.
Index: include/llvm/Target/TargetLowering.h
===================================================================
--- include/llvm/Target/TargetLowering.h
+++ include/llvm/Target/TargetLowering.h
@@ -2125,6 +2125,15 @@
     return false;
   }
 
+  /// Return true if an fpext operation input to an \p Opcode operation is free
+  /// (for instance, because half-precision floating-point numbers are
+  /// implicitly extended to float-precision) for an FMA instruction.
+  virtual bool isFPExtFree(unsigned Opcode, EVT DestVT) const {
+    // TODO: SrcVT may be useful.
+    assert(DestVT.isFloatingPoint());
+    return isFPExtFree(DestVT);
+  }
+
   /// Return true if folding a vector load into ExtVal (a sign, zero, or any
   /// extend node) is profitable.
   virtual bool isVectorLoadExtDesirable(SDValue ExtVal) const { return false; }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36706.117841.patch
Type: text/x-patch
Size: 1854 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171005/82d7b804/attachment.bin>


More information about the llvm-commits mailing list