[llvm] 0f94c3c - [NFC][DAGCombine] Extract getFirstIndexOf() lambda back into a function

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 14 06:26:29 PDT 2021


Author: Roman Lebedev
Date: 2021-06-14T16:25:59+03:00
New Revision: 0f94c3c80dde666f369ef98057ac943e869c3d52

URL: https://github.com/llvm/llvm-project/commit/0f94c3c80dde666f369ef98057ac943e869c3d52
DIFF: https://github.com/llvm/llvm-project/commit/0f94c3c80dde666f369ef98057ac943e869c3d52.diff

LOG: [NFC][DAGCombine] Extract getFirstIndexOf() lambda back into a function

Not all supported compilers like such lambdas, at least one buildbot is unhappy.

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 20e80df1dbac..8731cdc9f4b6 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -19266,6 +19266,15 @@ static SDValue reduceBuildVecToShuffleWithZero(SDNode *BV, SelectionDAG &DAG) {
   return DAG.getBitcast(VT, Shuf);
 }
 
+// FIXME: promote to STLExtras.
+template <typename R, typename T>
+static auto getFirstIndexOf(R &&Range, const T &Val) {
+  auto I = find(Range, Val);
+  if (I == Range.end())
+    return -1L;
+  return std::distance(Range.begin(), I);
+}
+
 // Check to see if this is a BUILD_VECTOR of a bunch of EXTRACT_VECTOR_ELT
 // operations. If the types of the vectors we're extracting from allow it,
 // turn this into a vector_shuffle node.
@@ -19273,14 +19282,6 @@ SDValue DAGCombiner::reduceBuildVecToShuffle(SDNode *N) {
   SDLoc DL(N);
   EVT VT = N->getValueType(0);
 
-  // FIXME: promote to STLExtras.
-  auto getFirstIndexOf = [](auto &&Range, const auto &Val) {
-    auto I = find(Range, Val);
-    if (I == Range.end())
-      return -1L;
-    return std::distance(Range.begin(), I);
-  };
-
   // Only type-legal BUILD_VECTOR nodes are converted to shuffle nodes.
   if (!isTypeLegal(VT))
     return SDValue();


        


More information about the llvm-commits mailing list