[llvm] c1fb8bd - [BasicTTI] Add missing scalable vector handling

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 6 14:21:55 PDT 2022


Author: Philip Reames
Date: 2022-06-06T14:21:41-07:00
New Revision: c1fb8bd7775e1ae420c36e6f90974617f77a9227

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

LOG: [BasicTTI] Add missing scalable vector handling

BasicTTI needs to return an invalid cost for scalable vectors instead of crash.  Without this, it is impossible to write tests for missing functionality in a target.

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/BasicTTIImpl.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index c1b9533b6fc1..8c54ce879fb9 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -2130,6 +2130,11 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
   /// vector is reduced on each iteration.
   InstructionCost getTreeReductionCost(unsigned Opcode, VectorType *Ty,
                                        TTI::TargetCostKind CostKind) {
+    // Targets must implement a default value for the scalable case, since
+    // we don't know how many lanes the vector has.
+    if (isa<ScalableVectorType>(Ty))
+      return InstructionCost::getInvalid();
+
     Type *ScalarTy = Ty->getElementType();
     unsigned NumVecElts = cast<FixedVectorType>(Ty)->getNumElements();
     if ((Opcode == Instruction::Or || Opcode == Instruction::And) &&
@@ -2228,6 +2233,11 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
   InstructionCost getMinMaxReductionCost(VectorType *Ty, VectorType *CondTy,
                                          bool IsUnsigned,
                                          TTI::TargetCostKind CostKind) {
+    // Targets must implement a default value for the scalable case, since
+    // we don't know how many lanes the vector has.
+    if (isa<ScalableVectorType>(Ty))
+      return InstructionCost::getInvalid();
+
     Type *ScalarTy = Ty->getElementType();
     Type *ScalarCondTy = CondTy->getElementType();
     unsigned NumVecElts = cast<FixedVectorType>(Ty)->getNumElements();


        


More information about the llvm-commits mailing list