@@ -2799,7 +2799,6 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg,
27992799 case Intrinsic::spv_firstbitshigh: // There is no CL equivalent of FindSMsb
28002800 return selectFirstBitHigh (ResVReg, ResType, I, /* IsSigned=*/ true );
28012801 case Intrinsic::spv_firstbitlow: // There is no CL equivlent of FindILsb
2802- // (true?)
28032802 return selectFirstBitLow (ResVReg, ResType, I);
28042803 case Intrinsic::spv_group_memory_barrier_with_group_sync: {
28052804 bool Result = true ;
@@ -3248,7 +3247,7 @@ bool SPIRVInstructionSelector::selectFirstBitLow64(Register ResVReg,
32483247 // Per the spec, repeat the vector if only one vec is needed
32493248 .addUse (FBLReg);
32503249
3251- // high bits are store in even indexes. Extract them from FBLReg
3250+ // high bits are stored in even indexes. Extract them from FBLReg
32523251 for (unsigned j = 0 ; j < ComponentCount * 2 ; j += 2 ) {
32533252 MIB.addImm (j);
32543253 }
@@ -3262,14 +3261,14 @@ bool SPIRVInstructionSelector::selectFirstBitLow64(Register ResVReg,
32623261 // Per the spec, repeat the vector if only one vec is needed
32633262 .addUse (FBLReg);
32643263
3265- // low bits are store in odd indexes. Extract them from FBLReg
3264+ // low bits are stored in odd indexes. Extract them from FBLReg
32663265 for (unsigned j = 1 ; j < ComponentCount * 2 ; j += 2 ) {
32673266 MIB.addImm (j);
32683267 }
32693268 Result = Result && MIB.constrainAllUses (TII, TRI, RBI);
32703269 }
32713270
3272- // 4. Check if result of each bottom 32 bits is == -1
3271+ // 4. Check the result. When low bits == -1 use high, otherwise use low
32733272 SPIRVType *BoolType = GR.getOrCreateSPIRVBoolType (I, TII);
32743273 Register NegOneReg;
32753274 Register Reg0;
@@ -3295,7 +3294,7 @@ bool SPIRVInstructionSelector::selectFirstBitLow64(Register ResVReg,
32953294 AddOp = SPIRV::OpIAddV;
32963295 }
32973296
3298- // Check if the low bits are == -1; true if -1
3297+ // Check if the low bits are == -1
32993298 Register BReg = MRI->createVirtualRegister (GR.getRegClass (BoolType));
33003299 Result = Result && selectNAryOpWithSrcs (BReg, BoolType, I,
33013300 {LowReg, NegOneReg}, SPIRV::OpIEqual);
@@ -3305,7 +3304,7 @@ bool SPIRVInstructionSelector::selectFirstBitLow64(Register ResVReg,
33053304 Result = Result && selectNAryOpWithSrcs (TmpReg, ResType, I,
33063305 {BReg, HighReg, LowReg}, SelectOp);
33073306
3308- // Add 32 for high bits, 0 for low bits
3307+ // 5. Add 32 when high bits are used, otherwise 0 for low bits
33093308 Register ValReg = MRI->createVirtualRegister (GR.getRegClass (ResType));
33103309 Result = Result && selectNAryOpWithSrcs (ValReg, ResType, I,
33113310 {BReg, Reg32, Reg0}, SelectOp);
0 commit comments