[PATCH] Remove non-necessary canonicalization from the DAG

Mehdi AMINI mehdi.amini at apple.com
Wed Apr 29 20:53:50 PDT 2015


Hi spatel,

r236031 introduced a transformation to reduce the dependency chain
for a sequence of binop instructions.

  (fadd N0: (fadd N00: (fadd z, w), N01: y), N1: x) ->
  (fadd N00: (fadd z, w), (fadd N1: x, N01: y))

However as part of the implementation, a canonicalization was
introduced that commute chain of fadd to be on the left side:

  (fadd (otherop, fadd)) -> (fadd (fadd, otherop))

This canonicalization does not seem required to perform the original
targetted transformation, swapping the operand locally is enough to
achieve this goal as far as I understand. Moreover the DAG is already
slow and the way it was done required a round trip through the
combiner queue and the creation of a temporary node.

http://reviews.llvm.org/D9363

Files:
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -7656,9 +7656,9 @@
   unsigned Opcode = N->getOpcode();
 
   // Canonicalize chains of this operation to LHS to allow the following fold.
-  if (N0.getOpcode() != Opcode && N1.getOpcode() == Opcode)
-    return DAG.getNode(Opcode, DL, VT, N1, N0);
-  
+  if (N1.getOpcode() == Opcode && N1.hasOneUse() && N0.getOpcode() != Opcode)
+    std::swap(N1, N0);
+
   // Convert a chain of 3 dependent operations into 2 independent operations
   // and 1 dependent operation:
   //  (op N0: (op N00: (op z, w), N01: y), N1: x) ->

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9363.24676.patch
Type: text/x-patch
Size: 731 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150430/ece1f75c/attachment.bin>


More information about the llvm-commits mailing list