[PATCH] [DAGCombiner] Combine shuffles of BUILD_VECTOR and SCALAR_TO_VECTOR

hfinkel at anl.gov hfinkel at anl.gov
Mon Mar 23 12:20:58 PDT 2015


> At the moment the inputs are only combined if they are only being used once - I'm interested in extending this so that constant inputs are always combined. It would create more constant data but would remove more shuffles (which may be introducing their own constant data for masks anyhow). Comments please.


We need to be careful here. Constant loads can be much more expensive than shuffles on some targets.


REPOSITORY
  rL LLVM

================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:12019
@@ +12018,3 @@
+        } else if (S.getOpcode() == ISD::SCALAR_TO_VECTOR && S.hasOneUse()) {
+          if(Idx == 0)
+            Op = S.getOperand(0);
----------------
Add space after if.

================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:12029
@@ +12028,3 @@
+    }
+    if (Ops.size() == VT.getVectorNumElements()) {
+      // Create SCALAR_TO_VECTOR if the only defined input is input[0].
----------------
When would this be false?

================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:12042
@@ +12041,3 @@
+        for (SDValue &Op : Ops)
+          Op = DAG.getSExtOrTrunc(Op, SDLoc(N), SVT);
+      return DAG.getNode(ISD::BUILD_VECTOR, SDLoc(N), VT, Ops);
----------------
It might be better to use ZExt, depending on the target/type. Might be better to use something like this:
  Op = isZExtFree(Op.getValueType(), SVT) ? DAG.getZExtOrTrunc(Op, SDLoc(N), SVT) : DAG.getSExtOrTrunc(Op, SDLoc(N), SVT);

http://reviews.llvm.org/D8516

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list