@@ -1815,20 +1815,23 @@ static bool generateImageSizeQueryInst(const SPIRV::IncomingCall *Call,
18151815 // Query result may either be a vector or a scalar. If return type is not a
18161816 // vector, expect only a single size component. Otherwise get the number of
18171817 // expected components.
1818- SPIRVType *RetTy = Call-> ReturnType ;
1819- unsigned NumExpectedRetComponents = RetTy ->getOpcode () == SPIRV::OpTypeVector
1820- ? RetTy ->getOperand (2 ).getImm ()
1821- : 1 ;
1818+ unsigned NumExpectedRetComponents =
1819+ Call-> ReturnType ->getOpcode () == SPIRV::OpTypeVector
1820+ ? Call-> ReturnType ->getOperand (2 ).getImm ()
1821+ : 1 ;
18221822 // Get the actual number of query result/size components.
18231823 SPIRVType *ImgType = GR->getSPIRVTypeForVReg (Call->Arguments [0 ]);
18241824 unsigned NumActualRetComponents = getNumSizeComponents (ImgType);
18251825 Register QueryResult = Call->ReturnRegister ;
18261826 SPIRVType *QueryResultType = Call->ReturnType ;
18271827 if (NumExpectedRetComponents != NumActualRetComponents) {
1828+ unsigned Bitwidth = Call->ReturnType ->getOpcode () == SPIRV::OpTypeInt
1829+ ? Call->ReturnType ->getOperand (1 ).getImm ()
1830+ : 32 ;
18281831 QueryResult = MIRBuilder.getMRI ()->createGenericVirtualRegister (
1829- LLT::fixed_vector (NumActualRetComponents, 32 ));
1832+ LLT::fixed_vector (NumActualRetComponents, Bitwidth ));
18301833 MIRBuilder.getMRI ()->setRegClass (QueryResult, &SPIRV::vIDRegClass);
1831- SPIRVType *IntTy = GR->getOrCreateSPIRVIntegerType (32 , MIRBuilder);
1834+ SPIRVType *IntTy = GR->getOrCreateSPIRVIntegerType (Bitwidth , MIRBuilder);
18321835 QueryResultType = GR->getOrCreateSPIRVVectorType (
18331836 IntTy, NumActualRetComponents, MIRBuilder, true );
18341837 GR->assignSPIRVTypeToVReg (QueryResultType, QueryResult, MIRBuilder.getMF ());
0 commit comments