From b431cc853809c98194c000c1e29b5b5ff22f687b Mon Sep 17 00:00:00 2001 From: Mariya Podchishchaeva Date: Tue, 24 Aug 2021 16:54:59 +0300 Subject: [PATCH] Fix support of SPV_INTEL_vector_compute The previous patch has fixed only case with 1-element vectors, however after closer look at the spec it became clear that SPV_INTEL_vector_compute actually allows any number of vector elements (capability VectorAnyINTEL), so this is the proper fix. --- .../SPIRV/SPIRVLowerBitCastToNonStandardType.cpp | 16 ++++++++-------- .../test/lower-non-standard-vec-with-ext.ll | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/llvm-spirv/lib/SPIRV/SPIRVLowerBitCastToNonStandardType.cpp b/llvm-spirv/lib/SPIRV/SPIRVLowerBitCastToNonStandardType.cpp index e67b0d8e790b0..a67c51a421b61 100644 --- a/llvm-spirv/lib/SPIRV/SPIRVLowerBitCastToNonStandardType.cpp +++ b/llvm-spirv/lib/SPIRV/SPIRVLowerBitCastToNonStandardType.cpp @@ -160,11 +160,11 @@ class SPIRVLowerBitCastToNonStandardTypePass VectorType *SrcVecTy = getVectorType(BC->getSrcTy()); if (SrcVecTy) { uint64_t NumElemsInSrcVec = SrcVecTy->getElementCount().getValue(); - // SPV_INTEL_vector_compute allows 1-element vectors + // SPV_INTEL_vector_compute allows to use vectors with any number of + // components if (!isValidVectorSize(NumElemsInSrcVec) && - !(Opts.isAllowedToUseExtension( - ExtensionID::SPV_INTEL_vector_compute) && - NumElemsInSrcVec == 1)) + !Opts.isAllowedToUseExtension( + ExtensionID::SPV_INTEL_vector_compute)) report_fatal_error("Unsupported vector type with the size of: " + std::to_string(NumElemsInSrcVec), false); @@ -172,11 +172,11 @@ class SPIRVLowerBitCastToNonStandardTypePass VectorType *DestVecTy = getVectorType(BC->getDestTy()); if (DestVecTy) { uint64_t NumElemsInDestVec = DestVecTy->getElementCount().getValue(); - // SPV_INTEL_vector_compute allows 1-element vectors + // SPV_INTEL_vector_compute allows to use vectors with any number of + // components if (!isValidVectorSize(NumElemsInDestVec) && - !(Opts.isAllowedToUseExtension( - ExtensionID::SPV_INTEL_vector_compute) && - NumElemsInDestVec == 1)) + !Opts.isAllowedToUseExtension( + ExtensionID::SPV_INTEL_vector_compute)) BCastsToNonStdVec.push_back(&I); } } diff --git a/llvm-spirv/test/lower-non-standard-vec-with-ext.ll b/llvm-spirv/test/lower-non-standard-vec-with-ext.ll index b1b709367ef22..711ca17858683 100644 --- a/llvm-spirv/test/lower-non-standard-vec-with-ext.ll +++ b/llvm-spirv/test/lower-non-standard-vec-with-ext.ll @@ -15,6 +15,7 @@ entry: %1 = extractelement <4 x i8> %0, i32 0 %2 = bitcast <1 x i32> to <4 x i8> %3 = extractelement <4 x i8> %2, i32 0 + %4 = bitcast <5 x i32> to <20 x i8> ret void }