[PATCH] [CodeGen] Combine concat_vectors(trunc(scalar), undef) -> scalar_to_vector(scalar)

Chandler Carruth chandlerc at gmail.com
Wed Apr 8 19:41:02 PDT 2015


Minor fixes below. LGTM with those fixes. Thanks!


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:11517-11519
@@ +11516,5 @@
+  // Optimize concat_vectors where all but the first of the vectors are undef.
+  auto IsUndef = [](const SDValue &Op) {
+    return ISD::UNDEF == Op.getOpcode();
+  };
+  bool AllButFirstUndefs =
----------------
Inline this into the std::all_of?

================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:11520-11522
@@ -11519,1 +11519,5 @@
+  };
+  bool AllButFirstUndefs =
+      std::all_of(N->op_begin() + 1, N->op_end(), IsUndef);
+  if (AllButFirstUndefs) {
     SDValue In = N->getOperand(0);
----------------
Why the boolean variable? I'd just put the std::all_of in the if...

nit: I prefer std::next to adding one to the begin.

http://reviews.llvm.org/D8883

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






More information about the llvm-commits mailing list