diff options
| author | Craig Topper <craig.topper@intel.com> | 2019-03-08 07:33:43 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2019-03-08 07:33:43 +0000 |
| commit | 4505c99e7222885ecb746a913fc33aa9098cf098 (patch) | |
| tree | b4292c74588632e1c2459532320ffc683e92a309 /llvm/lib | |
| parent | bd83f7097c52e173fa39902996cfd2ba6cce947d (diff) | |
| download | bcm5719-llvm-4505c99e7222885ecb746a913fc33aa9098cf098.tar.gz bcm5719-llvm-4505c99e7222885ecb746a913fc33aa9098cf098.zip | |
[X86] Improve the type checking in isLegalMaskedLoad and isLegalMaskedGather.
We were just checking pointer size and type primitive size. But this caused unintended things like vectors of half being accepted by masked load/store.
For FP we now explicitly check for only double and float.
For pointers we now let any pointer through. Trusting that only 32 and 64 would be used to generate assembly.
We only check bitwidth after checking that the type is an integer.
llvm-svn: 355667
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/X86/X86TargetTransformInfo.cpp | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp index 90adb3a4146..4529c2c5b83 100644 --- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp +++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp @@ -2988,15 +2988,26 @@ bool X86TTIImpl::canMacroFuseCmp() { } bool X86TTIImpl::isLegalMaskedLoad(Type *DataTy) { + if (!ST->hasAVX()) + return false; + // 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(); - return ((DataWidth == 32 || DataWidth == 64) && ST->hasAVX()) || - ((DataWidth == 8 || DataWidth == 16) && ST->hasBWI()); + if (ScalarTy->isPointerTy()) + return true; + + if (ScalarTy->isFloatTy() || ScalarTy->isDoubleTy()) + return true; + + if (!ScalarTy->isIntegerTy()) + return false; + + unsigned IntWidth = ScalarTy->getIntegerBitWidth(); + return IntWidth == 32 || IntWidth == 64 || + ((IntWidth == 8 || IntWidth == 16) && ST->hasBWI()); } bool X86TTIImpl::isLegalMaskedStore(Type *DataType) { @@ -3004,6 +3015,12 @@ bool X86TTIImpl::isLegalMaskedStore(Type *DataType) { } bool X86TTIImpl::isLegalMaskedGather(Type *DataTy) { + // Some CPUs have better gather performance than others. + // TODO: Remove the explicit ST->hasAVX512()?, That would mean we would only + // enable gather with a -march. + if (!(ST->hasAVX512() || (ST->hasFastGather() && ST->hasAVX2()))) + return false; + // This function is called now in two cases: from the Loop Vectorizer // and from the Scalarizer. // When the Loop Vectorizer asks about legality of the feature, @@ -3022,14 +3039,17 @@ bool X86TTIImpl::isLegalMaskedGather(Type *DataTy) { return false; } Type *ScalarTy = DataTy->getScalarType(); - int DataWidth = isa<PointerType>(ScalarTy) ? - DL.getPointerSizeInBits() : ScalarTy->getPrimitiveSizeInBits(); + if (ScalarTy->isPointerTy()) + return true; - // Some CPUs have better gather performance than others. - // TODO: Remove the explicit ST->hasAVX512()?, That would mean we would only - // enable gather with a -march. - return (DataWidth == 32 || DataWidth == 64) && - (ST->hasAVX512() || (ST->hasFastGather() && ST->hasAVX2())); + if (ScalarTy->isFloatTy() || ScalarTy->isDoubleTy()) + return true; + + if (!ScalarTy->isIntegerTy()) + return false; + + unsigned IntWidth = ScalarTy->getIntegerBitWidth(); + return IntWidth == 32 || IntWidth == 64; } bool X86TTIImpl::isLegalMaskedScatter(Type *DataType) { |

