@@ -2252,8 +2252,8 @@ bool SPIRVInstructionSelector::selectDot4AddPackedExpansion(
22522252 .addDef (AElt)
22532253 .addUse (GR.getSPIRVTypeID (ResType))
22542254 .addUse (X)
2255- .addUse (GR.getOrCreateConstInt (i * 8 , I, EltType, TII, ZeroAsNull))
2256- .addUse (GR.getOrCreateConstInt (8 , I, EltType, TII, ZeroAsNull))
2255+ .addUse (GR.getOrCreateConstInt (APInt ( 8 , i * 8 ) , I, EltType, TII, ZeroAsNull))
2256+ .addUse (GR.getOrCreateConstInt (APInt ( 8 , 8 ) , I, EltType, TII, ZeroAsNull))
22572257 .constrainAllUses (TII, TRI, RBI);
22582258
22592259 // B[i]
@@ -2263,8 +2263,8 @@ bool SPIRVInstructionSelector::selectDot4AddPackedExpansion(
22632263 .addDef (BElt)
22642264 .addUse (GR.getSPIRVTypeID (ResType))
22652265 .addUse (Y)
2266- .addUse (GR.getOrCreateConstInt (i * 8 , I, EltType, TII, ZeroAsNull))
2267- .addUse (GR.getOrCreateConstInt (8 , I, EltType, TII, ZeroAsNull))
2266+ .addUse (GR.getOrCreateConstInt (APInt ( 8 , i * 8 ) , I, EltType, TII, ZeroAsNull))
2267+ .addUse (GR.getOrCreateConstInt (APInt ( 8 , 8 ) , I, EltType, TII, ZeroAsNull))
22682268 .constrainAllUses (TII, TRI, RBI);
22692269
22702270 // A[i] * B[i]
@@ -2283,8 +2283,8 @@ bool SPIRVInstructionSelector::selectDot4AddPackedExpansion(
22832283 .addDef (MaskMul)
22842284 .addUse (GR.getSPIRVTypeID (ResType))
22852285 .addUse (Mul)
2286- .addUse (GR.getOrCreateConstInt (0 , I, EltType, TII, ZeroAsNull))
2287- .addUse (GR.getOrCreateConstInt (8 , I, EltType, TII, ZeroAsNull))
2286+ .addUse (GR.getOrCreateConstInt (APInt ( 8 , 0 ) , I, EltType, TII, ZeroAsNull))
2287+ .addUse (GR.getOrCreateConstInt (APInt ( 8 , 8 ) , I, EltType, TII, ZeroAsNull))
22882288 .constrainAllUses (TII, TRI, RBI);
22892289
22902290 // Acc = Acc + A[i] * B[i]
@@ -2381,7 +2381,7 @@ bool SPIRVInstructionSelector::selectWaveOpInst(Register ResVReg,
23812381 auto BMI = BuildMI (BB, I, I.getDebugLoc (), TII.get (Opcode))
23822382 .addDef (ResVReg)
23832383 .addUse (GR.getSPIRVTypeID (ResType))
2384- .addUse (GR.getOrCreateConstInt (SPIRV::Scope::Subgroup, I,
2384+ .addUse (GR.getOrCreateConstInt (APInt ( 32 , SPIRV::Scope::Subgroup) , I,
23852385 IntTy, TII, !STI.isShader ()));
23862386
23872387 for (unsigned J = 2 ; J < I.getNumOperands (); J++) {
@@ -2405,7 +2405,7 @@ bool SPIRVInstructionSelector::selectWaveActiveCountBits(
24052405 TII.get (SPIRV::OpGroupNonUniformBallotBitCount))
24062406 .addDef (ResVReg)
24072407 .addUse (GR.getSPIRVTypeID (ResType))
2408- .addUse (GR.getOrCreateConstInt (SPIRV::Scope::Subgroup, I, IntTy,
2408+ .addUse (GR.getOrCreateConstInt (APInt ( 32 , SPIRV::Scope::Subgroup) , I, IntTy,
24092409 TII, !STI.isShader ()))
24102410 .addImm (SPIRV::GroupOperation::Reduce)
24112411 .addUse (BallotReg)
@@ -2436,7 +2436,7 @@ bool SPIRVInstructionSelector::selectWaveReduceMax(Register ResVReg,
24362436 return BuildMI (BB, I, I.getDebugLoc (), TII.get (Opcode))
24372437 .addDef (ResVReg)
24382438 .addUse (GR.getSPIRVTypeID (ResType))
2439- .addUse (GR.getOrCreateConstInt (SPIRV::Scope::Subgroup, I, IntTy, TII,
2439+ .addUse (GR.getOrCreateConstInt (APInt ( 32 , SPIRV::Scope::Subgroup) , I, IntTy, TII,
24402440 !STI.isShader ()))
24412441 .addImm (SPIRV::GroupOperation::Reduce)
24422442 .addUse (I.getOperand (2 ).getReg ())
@@ -2463,7 +2463,7 @@ bool SPIRVInstructionSelector::selectWaveReduceSum(Register ResVReg,
24632463 return BuildMI (BB, I, I.getDebugLoc (), TII.get (Opcode))
24642464 .addDef (ResVReg)
24652465 .addUse (GR.getSPIRVTypeID (ResType))
2466- .addUse (GR.getOrCreateConstInt (SPIRV::Scope::Subgroup, I, IntTy, TII,
2466+ .addUse (GR.getOrCreateConstInt (APInt ( 32 , SPIRV::Scope::Subgroup) , I, IntTy, TII,
24672467 !STI.isShader ()))
24682468 .addImm (SPIRV::GroupOperation::Reduce)
24692469 .addUse (I.getOperand (2 ).getReg ());
@@ -2689,7 +2689,7 @@ Register SPIRVInstructionSelector::buildZerosVal(const SPIRVType *ResType,
26892689 bool ZeroAsNull = !STI.isShader ();
26902690 if (ResType->getOpcode () == SPIRV::OpTypeVector)
26912691 return GR.getOrCreateConstVector (0UL , I, ResType, TII, ZeroAsNull);
2692- return GR.getOrCreateConstInt (0 , I, ResType, TII, ZeroAsNull);
2692+ return GR.getOrCreateConstInt (APInt (GR. getScalarOrVectorBitWidth (ResType), 0 ) , I, ResType, TII, ZeroAsNull);
26932693}
26942694
26952695Register SPIRVInstructionSelector::buildZerosValF (const SPIRVType *ResType,
@@ -2720,7 +2720,7 @@ Register SPIRVInstructionSelector::buildOnesVal(bool AllOnes,
27202720 AllOnes ? APInt::getAllOnes (BitWidth) : APInt::getOneBitSet (BitWidth, 0 );
27212721 if (ResType->getOpcode () == SPIRV::OpTypeVector)
27222722 return GR.getOrCreateConstVector (One.getZExtValue (), I, ResType, TII);
2723- return GR.getOrCreateConstInt (One.getZExtValue (), I, ResType, TII);
2723+ return GR.getOrCreateConstInt (APInt (GR. getScalarOrVectorBitWidth (ResType), One.getZExtValue () ), I, ResType, TII);
27242724}
27252725
27262726bool SPIRVInstructionSelector::selectSelect (Register ResVReg,
@@ -2939,8 +2939,7 @@ bool SPIRVInstructionSelector::selectConst(Register ResVReg,
29392939 Reg = GR.getOrCreateConstFP (I.getOperand (1 ).getFPImm ()->getValue (), I,
29402940 ResType, TII, !STI.isShader ());
29412941 } else {
2942- Reg = GR.getOrCreateConstInt (I.getOperand (1 ).getCImm ()->getZExtValue (), I,
2943- ResType, TII, !STI.isShader ());
2942+ Reg = GR.getOrCreateConstInt (I.getOperand (1 ).getCImm ()->getValue (), I, ResType, TII, !STI.isShader ());
29442943 }
29452944 return Reg == ResVReg ? true : BuildCOPY (ResVReg, Reg, I);
29462945}
@@ -3765,7 +3764,7 @@ bool SPIRVInstructionSelector::selectFirstBitSet64Overflow(
37653764 bool ZeroAsNull = !STI.isShader ();
37663765 Register FinalElemReg = MRI->createVirtualRegister (GR.getRegClass (I64Type));
37673766 Register ConstIntLastIdx = GR.getOrCreateConstInt (
3768- ComponentCount - 1 , I, BaseType, TII, ZeroAsNull);
3767+ APInt (GR. getScalarOrVectorBitWidth (BaseType), ComponentCount - 1 ) , I, BaseType, TII, ZeroAsNull);
37693768
37703769 if (!selectOpWithSrcs (FinalElemReg, I64Type, I, {SrcReg, ConstIntLastIdx},
37713770 SPIRV::OpVectorExtractDynamic))
@@ -3794,9 +3793,9 @@ bool SPIRVInstructionSelector::selectFirstBitSet64(
37943793 SPIRVType *BaseType = GR.retrieveScalarOrVectorIntType (ResType);
37953794 bool ZeroAsNull = !STI.isShader ();
37963795 Register ConstIntZero =
3797- GR.getOrCreateConstInt (0 , I, BaseType, TII, ZeroAsNull);
3796+ GR.getOrCreateConstInt (APInt (GR. getScalarOrVectorBitWidth (BaseType), 0 ) , I, BaseType, TII, ZeroAsNull);
37983797 Register ConstIntOne =
3799- GR.getOrCreateConstInt (1 , I, BaseType, TII, ZeroAsNull);
3798+ GR.getOrCreateConstInt (APInt (GR. getScalarOrVectorBitWidth (BaseType), 1 ) , I, BaseType, TII, ZeroAsNull);
38003799
38013800 // SPIRV doesn't support vectors with more than 4 components. Since the
38023801 // algoritm below converts i64 -> i32x2 and i64x4 -> i32x8 it can only
@@ -3881,9 +3880,9 @@ bool SPIRVInstructionSelector::selectFirstBitSet64(
38813880
38823881 if (IsScalarRes) {
38833882 NegOneReg =
3884- GR.getOrCreateConstInt (( unsigned )-1 , I, ResType, TII, ZeroAsNull);
3885- Reg0 = GR.getOrCreateConstInt (0 , I, ResType, TII, ZeroAsNull);
3886- Reg32 = GR.getOrCreateConstInt (32 , I, ResType, TII, ZeroAsNull);
3883+ GR.getOrCreateConstInt (APInt (GR. getScalarOrVectorBitWidth (ResType), ( unsigned )-1 ) , I, ResType, TII, ZeroAsNull);
3884+ Reg0 = GR.getOrCreateConstInt (APInt (GR. getScalarOrVectorBitWidth (ResType), 0 ) , I, ResType, TII, ZeroAsNull);
3885+ Reg32 = GR.getOrCreateConstInt (APInt (GR. getScalarOrVectorBitWidth (ResType), 32 ) , I, ResType, TII, ZeroAsNull);
38873886 SelectOp = SPIRV::OpSelectSISCond;
38883887 AddOp = SPIRV::OpIAddS;
38893888 } else {
0 commit comments