[llvm] 3a726bc - [SVE] Bail from cstfp_pred_ty before walking scalable vector

Christopher Tetreault via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 15 13:53:06 PDT 2020


Author: Christopher Tetreault
Date: 2020-06-15T13:52:50-07:00
New Revision: 3a726bc9935bf1e0c4b8f273c0b981002902bb66

URL: https://github.com/llvm/llvm-project/commit/3a726bc9935bf1e0c4b8f273c0b981002902bb66
DIFF: https://github.com/llvm/llvm-project/commit/3a726bc9935bf1e0c4b8f273c0b981002902bb66.diff

LOG: [SVE] Bail from cstfp_pred_ty before walking scalable vector

Summary:
Bail out in cstfp_pred_ty before calling getNumElements and walking the
vector if the vector is scalable.

Reviewers: efriedma, lebedev.ri, fhahn, sdesmalen, fpetrogalli

Reviewed By: sdesmalen

Subscribers: tschuett, rkruppe, psnobl, llvm-commits

Tags: #llvm

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/PatternMatch.h b/llvm/include/llvm/IR/PatternMatch.h
index 5f1c8b8ffaf7..98182bc3d85d 100644
--- a/llvm/include/llvm/IR/PatternMatch.h
+++ b/llvm/include/llvm/IR/PatternMatch.h
@@ -333,6 +333,10 @@ template <typename Predicate> struct cstfp_pred_ty : public Predicate {
         if (const auto *CF = dyn_cast_or_null<ConstantFP>(C->getSplatValue()))
           return this->isValue(CF->getValueAPF());
 
+        // Number of elements of a scalable vector unknown at compile time
+        if (isa<ScalableVectorType>(V->getType()))
+          return false;
+
         // Non-splat vector constant: check each element for a match.
         unsigned NumElts = cast<VectorType>(V->getType())->getNumElements();
         assert(NumElts != 0 && "Constant vector with no elements?");


        


More information about the llvm-commits mailing list