[X86] Update TTI to report that v1iX/v1fX types aren't legal for masked gather/scatter/load/store.
The type legalizer will try to scalarize these operations if it sees them, but there is no handling for scalarizing them. This leads to a fatal error. With this change they will now be scalarized by the mem intrinsic scalarizing pass before SelectionDAG.
llvm-svn: 318380
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index 6772d96..28c5d04 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -2478,6 +2478,9 @@
}
bool X86TTIImpl::isLegalMaskedLoad(Type *DataTy) {
+ // The backend can't handle a single element vector.
+ if (isa<VectorType>(DataTy) && DataTy->getVectorNumElements() == 1)
+ return false;
Type *ScalarTy = DataTy->getScalarType();
int DataWidth = isa<PointerType>(ScalarTy) ?
DL.getPointerSizeInBits() : ScalarTy->getPrimitiveSizeInBits();
@@ -2501,8 +2504,13 @@
// the vector type.
// The Scalarizer asks again about legality. It sends a vector type.
// In this case we can reject non-power-of-2 vectors.
- if (isa<VectorType>(DataTy) && !isPowerOf2_32(DataTy->getVectorNumElements()))
- return false;
+ // We also reject single element vectors as the type legalizer can't
+ // scalarize it.
+ if (isa<VectorType>(DataTy)) {
+ unsigned NumElts = DataTy->getVectorNumElements();
+ if (NumElts == 1 || !isPowerOf2_32(NumElts))
+ return false;
+ }
Type *ScalarTy = DataTy->getScalarType();
int DataWidth = isa<PointerType>(ScalarTy) ?
DL.getPointerSizeInBits() : ScalarTy->getPrimitiveSizeInBits();