[llvm] 1d49e53 - [llvm] remove Sequence::asSmallVector()

Guillaume Chatelet via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 14 01:28:19 PDT 2021


Author: Guillaume Chatelet
Date: 2021-06-14T08:28:05Z
New Revision: 1d49e5352f9538bb9c514dd627a93f9c40982d3a

URL: https://github.com/llvm/llvm-project/commit/1d49e5352f9538bb9c514dd627a93f9c40982d3a
DIFF: https://github.com/llvm/llvm-project/commit/1d49e5352f9538bb9c514dd627a93f9c40982d3a.diff

LOG: [llvm] remove Sequence::asSmallVector()

There's no need for `toSmallVector()` as `SmallVector.h` already provides a `to_vector` free function that takes a range.

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D104024

Added: 
    

Modified: 
    llvm/include/llvm/ADT/Sequence.h
    mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
    mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/Sequence.h b/llvm/include/llvm/ADT/Sequence.h
index 44e46a40b845..d033c01ecc57 100644
--- a/llvm/include/llvm/ADT/Sequence.h
+++ b/llvm/include/llvm/ADT/Sequence.h
@@ -15,8 +15,6 @@
 #ifndef LLVM_ADT_SEQUENCE_H
 #define LLVM_ADT_SEQUENCE_H
 
-#include "llvm/ADT/SmallVector.h"
-
 #include <cstddef>  //std::ptr
diff _t
 #include <iterator> //std::random_access_iterator_tag
 
@@ -167,8 +165,6 @@ template <typename ValueT> struct iota_range {
   auto rbegin() const { return const_reverse_iterator(End - 1); }
   auto rend() const { return const_reverse_iterator(Begin - 1); }
 
-  auto asSmallVector() const { return SmallVector<ValueT>(begin(), end()); }
-
 private:
   static_assert(std::is_same<ValueT, std::remove_cv_t<ValueT>>::value,
                 "ValueT must not be const nor volatile");

diff  --git a/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp b/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
index 402c89fd5f85..0ea5119041ec 100644
--- a/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
+++ b/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
@@ -15,7 +15,9 @@
 #include "mlir/Pass/Pass.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/ScopedHashTable.h"
+#include "llvm/ADT/Sequence.h"
 #include "llvm/ADT/SetVector.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/TypeSwitch.h"
 
 using namespace mlir;
@@ -380,9 +382,8 @@ void PatternLowering::generateSwitch(SwitchNode *switchNode,
   if (kind == Predicates::OperandCountAtLeastQuestion ||
       kind == Predicates::ResultCountAtLeastQuestion) {
     // Order the children such that the cases are in reverse numerical order.
-    SmallVector<unsigned> sortedChildren =
-        llvm::seq<unsigned>(0, switchNode->getChildren().size())
-            .asSmallVector();
+    SmallVector<unsigned> sortedChildren = llvm::to_vector<16>(
+        llvm::seq<unsigned>(0, switchNode->getChildren().size()));
     llvm::sort(sortedChildren, [&](unsigned lhs, unsigned rhs) {
       return cast<UnsignedAnswer>(switchNode->getChild(lhs).first)->getValue() >
              cast<UnsignedAnswer>(switchNode->getChild(rhs).first)->getValue();

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
index 96846bfb6633..f7d219231972 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
@@ -24,6 +24,8 @@
 #include "mlir/Support/LLVM.h"
 #include "mlir/Transforms/RegionUtils.h"
 #include "llvm/ADT/ScopeExit.h"
+#include "llvm/ADT/Sequence.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/TypeSwitch.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
@@ -303,7 +305,7 @@ static VectorizationResult vectorizeLinalgIndex(OpBuilder &b, Operation *op,
   auto targetShape = linalgOp.computeStaticLoopSizes();
   // Compute a one-dimensional index vector for the index op dimension.
   SmallVector<int64_t> constantSeq =
-      llvm::seq<int64_t>(0, targetShape[indexOp.dim()]).asSmallVector();
+      llvm::to_vector<16>(llvm::seq<int64_t>(0, targetShape[indexOp.dim()]));
   ConstantOp constantOp =
       b.create<ConstantOp>(loc, b.getIndexVectorAttr(constantSeq));
   // Return the one-dimensional index vector if it lives in the trailing
@@ -318,7 +320,7 @@ static VectorizationResult vectorizeLinalgIndex(OpBuilder &b, Operation *op,
   auto broadCastOp = b.create<vector::BroadcastOp>(
       loc, VectorType::get(targetShape, b.getIndexType()), constantOp);
   SmallVector<int64_t> transposition =
-      llvm::seq<int64_t>(0, linalgOp.getNumLoops()).asSmallVector();
+      llvm::to_vector<16>(llvm::seq<int64_t>(0, linalgOp.getNumLoops()));
   std::swap(transposition.back(), transposition[indexOp.dim()]);
   auto transposeOp =
       b.create<vector::TransposeOp>(loc, broadCastOp, transposition);


        


More information about the llvm-commits mailing list