[llvm] bbf3fd4 - [BasicTTI] Return Invalid for scalable vectors reaching getScalarizationOverhead
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 20 15:15:11 PDT 2022
Author: Philip Reames
Date: 2022-06-20T13:19:11-07:00
New Revision: bbf3fd4af1653693c7ada225c07cbd485ad1463c
URL: https://github.com/llvm/llvm-project/commit/bbf3fd4af1653693c7ada225c07cbd485ad1463c
DIFF: https://github.com/llvm/llvm-project/commit/bbf3fd4af1653693c7ada225c07cbd485ad1463c.diff
LOG: [BasicTTI] Return Invalid for scalable vectors reaching getScalarizationOverhead
If we would scalarize a fixed vector, we know we can't do so for a scalable one. However, there's no need to crash, we can instead simply return a invalid cost which will work its way through the computation (since invalid is sticky), and the client should bail out.
Sorry for the lack of test here. The particular codepath I saw this reached on was the result of another bug.
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 b9fa6eefa4b9..c496f680e6b0 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -703,6 +703,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
bool Insert, bool Extract) {
/// FIXME: a bitfield is not a reasonable abstraction for talking about
/// which elements are needed from a scalable vector
+ if (isa<ScalableVectorType>(InTy))
+ return InstructionCost::getInvalid();
auto *Ty = cast<FixedVectorType>(InTy);
assert(DemandedElts.getBitWidth() == Ty->getNumElements() &&
@@ -725,6 +727,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
/// Helper wrapper for the DemandedElts variant of getScalarizationOverhead.
InstructionCost getScalarizationOverhead(VectorType *InTy, bool Insert,
bool Extract) {
+ if (isa<ScalableVectorType>(InTy))
+ return InstructionCost::getInvalid();
auto *Ty = cast<FixedVectorType>(InTy);
APInt DemandedElts = APInt::getAllOnes(Ty->getNumElements());
More information about the llvm-commits
mailing list