Skip to content

Commit 2dfcd27

Browse files
committed
add assert
1 parent 08a732a commit 2dfcd27

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3179,6 +3179,13 @@ bool SPIRVInstructionSelector::selectFirstBitSet64Overflow(
31793179
Register SrcReg, unsigned BitSetOpcode, bool SwapPrimarySide) const {
31803180

31813181
unsigned ComponentCount = GR.getScalarOrVectorComponentCount(ResType);
3182+
// SPIR-V only allow vecs of size 2,3,4. Calling with a larger vec requires
3183+
// creating a return type with an invalid vec size. If that is resolved
3184+
// then this function is valid up to vec8 as the intermediate splitting
3185+
// would create 2 vec4.
3186+
assert(ComponentCount < 5 && "Vec 5+ will generate invalid SPIR-V ops");
3187+
3188+
31823189
SPIRVType *BaseType = GR.retrieveScalarOrVectorIntType(ResType);
31833190
bool ZeroAsNull = STI.isOpenCLEnv();
31843191
Register ConstIntZero =

0 commit comments

Comments
 (0)