@@ -2908,7 +2908,6 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg,
2908
2908
case Intrinsic::spv_firstbitshigh: // There is no CL equivalent of FindSMsb
2909
2909
return selectFirstBitHigh (ResVReg, ResType, I, /* IsSigned=*/ true );
2910
2910
case Intrinsic::spv_firstbitlow: // There is no CL equivlent of FindILsb
2911
- // (true?)
2912
2911
return selectFirstBitLow (ResVReg, ResType, I);
2913
2912
case Intrinsic::spv_group_memory_barrier_with_group_sync: {
2914
2913
bool Result = true ;
@@ -3382,7 +3381,7 @@ bool SPIRVInstructionSelector::selectFirstBitLow64(Register ResVReg,
3382
3381
// Per the spec, repeat the vector if only one vec is needed
3383
3382
.addUse (FBLReg);
3384
3383
3385
- // high bits are store in even indexes. Extract them from FBLReg
3384
+ // high bits are stored in even indexes. Extract them from FBLReg
3386
3385
for (unsigned j = 0 ; j < ComponentCount * 2 ; j += 2 ) {
3387
3386
MIB.addImm (j);
3388
3387
}
@@ -3396,14 +3395,14 @@ bool SPIRVInstructionSelector::selectFirstBitLow64(Register ResVReg,
3396
3395
// Per the spec, repeat the vector if only one vec is needed
3397
3396
.addUse (FBLReg);
3398
3397
3399
- // low bits are store in odd indexes. Extract them from FBLReg
3398
+ // low bits are stored in odd indexes. Extract them from FBLReg
3400
3399
for (unsigned j = 1 ; j < ComponentCount * 2 ; j += 2 ) {
3401
3400
MIB.addImm (j);
3402
3401
}
3403
3402
Result = Result && MIB.constrainAllUses (TII, TRI, RBI);
3404
3403
}
3405
3404
3406
- // 4. Check if result of each bottom 32 bits is == -1
3405
+ // 4. Check the result. When low bits == -1 use high, otherwise use low
3407
3406
SPIRVType *BoolType = GR.getOrCreateSPIRVBoolType (I, TII);
3408
3407
Register NegOneReg;
3409
3408
Register Reg0;
@@ -3429,7 +3428,7 @@ bool SPIRVInstructionSelector::selectFirstBitLow64(Register ResVReg,
3429
3428
AddOp = SPIRV::OpIAddV;
3430
3429
}
3431
3430
3432
- // Check if the low bits are == -1; true if -1
3431
+ // Check if the low bits are == -1
3433
3432
Register BReg = MRI->createVirtualRegister (GR.getRegClass (BoolType));
3434
3433
Result = Result && selectNAryOpWithSrcs (BReg, BoolType, I,
3435
3434
{LowReg, NegOneReg}, SPIRV::OpIEqual);
@@ -3439,7 +3438,7 @@ bool SPIRVInstructionSelector::selectFirstBitLow64(Register ResVReg,
3439
3438
Result = Result && selectNAryOpWithSrcs (TmpReg, ResType, I,
3440
3439
{BReg, HighReg, LowReg}, SelectOp);
3441
3440
3442
- // Add 32 for high bits, 0 for low bits
3441
+ // 5. Add 32 when high bits are used, otherwise 0 for low bits
3443
3442
Register ValReg = MRI->createVirtualRegister (GR.getRegClass (ResType));
3444
3443
Result = Result && selectNAryOpWithSrcs (ValReg, ResType, I,
3445
3444
{BReg, Reg32, Reg0}, SelectOp);
0 commit comments