Skip to content

Commit e9671a5

Browse files
authored
Fix support of SPV_INTEL_vector_compute (#1176)
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.
1 parent 81ebabd commit e9671a5

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

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 1-element vectors
164-
if (!isValidVectorSize(NumElemsInSrcVec) &&
165-
!(Opts.isAllowedToUseExtension(
166-
ExtensionID::SPV_INTEL_vector_compute) &&
167-
NumElemsInSrcVec == 1))
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 1-element vectors
176-
if (!isValidVectorSize(NumElemsInDestVec) &&
177-
!(Opts.isAllowedToUseExtension(
178-
ExtensionID::SPV_INTEL_vector_compute) &&
179-
NumElemsInDestVec == 1))
178+
if (!isValidVectorSize(NumElemsInDestVec))
180179
BCastsToNonStdVec.push_back(&I);
181180
}
182181
}

test/lower-non-standard-vec-with-ext.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ entry:
1515
%1 = extractelement <4 x i8> %0, i32 0
1616
%2 = bitcast <1 x i32> <i32 131586> to <4 x i8>
1717
%3 = extractelement <4 x i8> %2, i32 0
18+
%4 = bitcast <5 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1> to <20 x i8>
1819
ret void
1920
}
2021

0 commit comments

Comments
 (0)