Skip to content

Commit 761df2f

Browse files
Fznamznonvmaksimo
authored andcommitted
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. This is a follow-up change for b431cc8. Original commit: KhronosGroup/SPIRV-LLVM-Translator@e9671a5
1 parent 739793e commit 761df2f

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

llvm-spirv/lib/SPIRV/SPIRVLowerBitCastToNonStandardType.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ class SPIRVLowerBitCastToNonStandardTypePass
150150
// parameter, since it added by an optimization.
151151
bool Changed = false;
152152

153+
// SPV_INTEL_vector_compute allows to use vectors with any number of
154+
// components. Since this method only lowers vectors with non-standard
155+
// in pure SPIR-V number of components, there is no need to do anything in
156+
// case SPV_INTEL_vector_compute is enabled.
157+
if (Opts.isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute))
158+
return PreservedAnalyses::all();
159+
153160
std::vector<Instruction *> BCastsToNonStdVec;
154161
std::vector<Instruction *> InstsToErase;
155162
for (auto &BB : F)
@@ -160,23 +167,15 @@ class SPIRVLowerBitCastToNonStandardTypePass
160167
VectorType *SrcVecTy = getVectorType(BC->getSrcTy());
161168
if (SrcVecTy) {
162169
uint64_t NumElemsInSrcVec = SrcVecTy->getElementCount().getValue();
163-
// SPV_INTEL_vector_compute allows to use vectors with any number of
164-
// components
165-
if (!isValidVectorSize(NumElemsInSrcVec) &&
166-
!Opts.isAllowedToUseExtension(
167-
ExtensionID::SPV_INTEL_vector_compute))
170+
if (!isValidVectorSize(NumElemsInSrcVec))
168171
report_fatal_error("Unsupported vector type with the size of: " +
169172
std::to_string(NumElemsInSrcVec),
170173
false);
171174
}
172175
VectorType *DestVecTy = getVectorType(BC->getDestTy());
173176
if (DestVecTy) {
174177
uint64_t NumElemsInDestVec = DestVecTy->getElementCount().getValue();
175-
// SPV_INTEL_vector_compute allows to use vectors with any number of
176-
// components
177-
if (!isValidVectorSize(NumElemsInDestVec) &&
178-
!Opts.isAllowedToUseExtension(
179-
ExtensionID::SPV_INTEL_vector_compute))
178+
if (!isValidVectorSize(NumElemsInDestVec))
180179
BCastsToNonStdVec.push_back(&I);
181180
}
182181
}

0 commit comments

Comments
 (0)