Skip to content

Commit c1b23a3

Browse files
svenvhdwoodwor-intel
authored andcommitted
Separate image operand and LoD handling
Original commit: KhronosGroup/SPIRV-LLVM-Translator@82f31a3
1 parent efec551 commit c1b23a3

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

llvm-spirv/lib/SPIRV/SPIRVToOCL.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -766,15 +766,21 @@ static char getTypeSuffix(Type *T) {
766766
}
767767

768768
void SPIRVToOCLBase::mutateArgsForImageOperands(std::vector<Value *> &Args) {
769-
if (Args.size() > 4) {
769+
if (Args.size() > 3) {
770770
ConstantInt *ImOp = dyn_cast<ConstantInt>(Args[3]);
771-
ConstantFP *LodVal = dyn_cast<ConstantFP>(Args[4]);
771+
uint64_t ImOpValue = 0;
772+
if (ImOp)
773+
ImOpValue = ImOp->getZExtValue();
772774
// Drop "Image Operands" argument.
773775
Args.erase(Args.begin() + 3, Args.begin() + 4);
774-
// If the image operand is LOD and its value is zero, drop it too.
775-
if (ImOp && LodVal && LodVal->isNullValue() &&
776-
ImOp->getZExtValue() == ImageOperandsMask::ImageOperandsLodMask)
777-
Args.erase(Args.begin() + 3, Args.end());
776+
777+
if (Args.size() > 3) {
778+
ConstantFP *LodVal = dyn_cast<ConstantFP>(Args[3]);
779+
// If the image operand is LOD and its value is zero, drop it too.
780+
if (LodVal && LodVal->isNullValue() &&
781+
ImOpValue == ImageOperandsMask::ImageOperandsLodMask)
782+
Args.erase(Args.begin() + 3, Args.end());
783+
}
778784
}
779785
}
780786

0 commit comments

Comments
 (0)