[PATCH] D79195: [SVE] Fix invalid use of VectorType::getNumElements() in PatternMatch

Christopher Tetreault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 1 17:29:14 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG0ee7b7e3f1bc: [SVE] Fix invalid use of VectorType::getNumElements() in PatternMatch (authored by ctetreau).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79195/new/

https://reviews.llvm.org/D79195

Files:
  llvm/include/llvm/IR/PatternMatch.h


Index: llvm/include/llvm/IR/PatternMatch.h
===================================================================
--- llvm/include/llvm/IR/PatternMatch.h
+++ llvm/include/llvm/IR/PatternMatch.h
@@ -262,20 +262,20 @@
   return constantint_match<Val>();
 }
 
-/// This helper class is used to match scalar and vector integer constants that
-/// satisfy a specified predicate.
+/// This helper class is used to match scalar and fixed width vector integer
+/// constants that satisfy a specified predicate.
 /// For vector constants, undefined elements are ignored.
 template <typename Predicate> struct cst_pred_ty : public Predicate {
   template <typename ITy> bool match(ITy *V) {
     if (const auto *CI = dyn_cast<ConstantInt>(V))
       return this->isValue(CI->getValue());
-    if (V->getType()->isVectorTy()) {
+    if (const auto *FVTy = dyn_cast<FixedVectorType>(V->getType())) {
       if (const auto *C = dyn_cast<Constant>(V)) {
         if (const auto *CI = dyn_cast_or_null<ConstantInt>(C->getSplatValue()))
           return this->isValue(CI->getValue());
 
         // Non-splat vector constant: check each element for a match.
-        unsigned NumElts = cast<VectorType>(V->getType())->getNumElements();
+        unsigned NumElts = FVTy->getNumElements();
         assert(NumElts != 0 && "Constant vector with no elements?");
         bool HasNonUndefElements = false;
         for (unsigned i = 0; i != NumElts; ++i) {
@@ -462,6 +462,7 @@
 struct is_zero {
   template <typename ITy> bool match(ITy *V) {
     auto *C = dyn_cast<Constant>(V);
+    // FIXME: this should be able to do something for scalable vectors
     return C && (C->isNullValue() || cst_pred_ty<is_zero_int>().match(C));
   }
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79195.261586.patch
Type: text/x-patch
Size: 1715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200502/f7c6895a/attachment.bin>


More information about the llvm-commits mailing list