@@ -2827,7 +2827,6 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg,
28272827 case Intrinsic::spv_firstbitshigh: // There is no CL equivalent of FindSMsb
28282828 return selectFirstBitHigh (ResVReg, ResType, I, /* IsSigned=*/ true );
28292829 case Intrinsic::spv_firstbitlow: // There is no CL equivlent of FindILsb
2830- // (true?)
28312830 return selectFirstBitLow (ResVReg, ResType, I);
28322831 case Intrinsic::spv_group_memory_barrier_with_group_sync: {
28332832 bool Result = true ;
@@ -3301,7 +3300,7 @@ bool SPIRVInstructionSelector::selectFirstBitLow64(Register ResVReg,
33013300 // Per the spec, repeat the vector if only one vec is needed
33023301 .addUse (FBLReg);
33033302
3304- // high bits are store in even indexes. Extract them from FBLReg
3303+ // high bits are stored in even indexes. Extract them from FBLReg
33053304 for (unsigned j = 0 ; j < ComponentCount * 2 ; j += 2 ) {
33063305 MIB.addImm (j);
33073306 }
@@ -3315,14 +3314,14 @@ bool SPIRVInstructionSelector::selectFirstBitLow64(Register ResVReg,
33153314 // Per the spec, repeat the vector if only one vec is needed
33163315 .addUse (FBLReg);
33173316
3318- // low bits are store in odd indexes. Extract them from FBLReg
3317+ // low bits are stored in odd indexes. Extract them from FBLReg
33193318 for (unsigned j = 1 ; j < ComponentCount * 2 ; j += 2 ) {
33203319 MIB.addImm (j);
33213320 }
33223321 Result = Result && MIB.constrainAllUses (TII, TRI, RBI);
33233322 }
33243323
3325- // 4. Check if result of each bottom 32 bits is == -1
3324+ // 4. Check the result. When low bits == -1 use high, otherwise use low
33263325 SPIRVType *BoolType = GR.getOrCreateSPIRVBoolType (I, TII);
33273326 Register NegOneReg;
33283327 Register Reg0;
@@ -3348,7 +3347,7 @@ bool SPIRVInstructionSelector::selectFirstBitLow64(Register ResVReg,
33483347 AddOp = SPIRV::OpIAddV;
33493348 }
33503349
3351- // Check if the low bits are == -1; true if -1
3350+ // Check if the low bits are == -1
33523351 Register BReg = MRI->createVirtualRegister (GR.getRegClass (BoolType));
33533352 Result = Result && selectNAryOpWithSrcs (BReg, BoolType, I,
33543353 {LowReg, NegOneReg}, SPIRV::OpIEqual);
@@ -3358,7 +3357,7 @@ bool SPIRVInstructionSelector::selectFirstBitLow64(Register ResVReg,
33583357 Result = Result && selectNAryOpWithSrcs (TmpReg, ResType, I,
33593358 {BReg, HighReg, LowReg}, SelectOp);
33603359
3361- // Add 32 for high bits, 0 for low bits
3360+ // 5. Add 32 when high bits are used, otherwise 0 for low bits
33623361 Register ValReg = MRI->createVirtualRegister (GR.getRegClass (ResType));
33633362 Result = Result && selectNAryOpWithSrcs (ValReg, ResType, I,
33643363 {BReg, Reg32, Reg0}, SelectOp);
0 commit comments