Skip to content

Commit 42d24e4

Browse files
committed
Address comments
1 parent e61310b commit 42d24e4

File tree

1 file changed

+7
-31
lines changed

1 file changed

+7
-31
lines changed

llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,11 @@ class SPIRVInstructionSelector : public InstructionSelector {
258258
MachineInstr &I) const;
259259

260260
bool selectWaveNOpInst(Register ResVReg, const SPIRVType *ResType,
261-
MachineInstr &I, unsigned Opcode,
262-
unsigned OperandCount) const;
263-
bool selectWaveActiveAnyTrue(Register ResVReg, const SPIRVType *ResType,
264-
MachineInstr &I) const;
261+
MachineInstr &I, unsigned Opcode) const;
265262

266263
bool selectWaveActiveCountBits(Register ResVReg, const SPIRVType *ResType,
267264
MachineInstr &I) const;
268265

269-
bool selectWaveReadLaneAt(Register ResVReg, const SPIRVType *ResType,
270-
MachineInstr &I) const;
271-
272266
bool selectUnmergeValues(MachineInstr &I) const;
273267

274268
bool selectHandleFromBinding(Register &ResVReg, const SPIRVType *ResType,
@@ -1958,13 +1952,7 @@ bool SPIRVInstructionSelector::selectSign(Register ResVReg,
19581952
bool SPIRVInstructionSelector::selectWaveNOpInst(Register ResVReg,
19591953
const SPIRVType *ResType,
19601954
MachineInstr &I,
1961-
unsigned Opcode,
1962-
unsigned OperandCount) const {
1963-
assert(I.getNumOperands() == OperandCount);
1964-
for (unsigned j = 2; j < OperandCount; j++) {
1965-
assert(I.getOperand(j).isReg());
1966-
}
1967-
1955+
unsigned Opcode) const {
19681956
MachineBasicBlock &BB = *I.getParent();
19691957
SPIRVType *IntTy = GR.getOrCreateSPIRVIntegerType(32, I, TII);
19701958

@@ -1974,27 +1962,21 @@ bool SPIRVInstructionSelector::selectWaveNOpInst(Register ResVReg,
19741962
.addUse(GR.getOrCreateConstInt(SPIRV::Scope::Subgroup, I,
19751963
IntTy, TII));
19761964

1977-
for (unsigned j = 2; j < OperandCount; j++) {
1965+
for (unsigned j = 2; j < I.getNumOperands(); j++) {
19781966
BMI.addUse(I.getOperand(j).getReg());
19791967
}
19801968

19811969
return BMI.constrainAllUses(TII, TRI, RBI);
19821970
}
19831971

1984-
bool SPIRVInstructionSelector::selectWaveActiveAnyTrue(Register ResVReg,
1985-
const SPIRVType *ResType,
1986-
MachineInstr &I) const {
1987-
return selectWaveNOpInst(ResVReg, ResType, I, SPIRV::OpGroupNonUniformAny, 3);
1988-
}
1989-
19901972
bool SPIRVInstructionSelector::selectWaveActiveCountBits(
19911973
Register ResVReg, const SPIRVType *ResType, MachineInstr &I) const {
19921974

19931975
SPIRVType *IntTy = GR.getOrCreateSPIRVIntegerType(32, I, TII);
19941976
SPIRVType *BallotType = GR.getOrCreateSPIRVVectorType(IntTy, 4, I, TII);
19951977
Register BallotReg = MRI->createVirtualRegister(GR.getRegClass(BallotType));
19961978
bool Result = selectWaveNOpInst(BallotReg, BallotType, I,
1997-
SPIRV::OpGroupNonUniformBallot, 3);
1979+
SPIRV::OpGroupNonUniformBallot);
19981980

19991981
MachineBasicBlock &BB = *I.getParent();
20001982
Result &=
@@ -2010,13 +1992,6 @@ bool SPIRVInstructionSelector::selectWaveActiveCountBits(
20101992
return Result;
20111993
}
20121994

2013-
bool SPIRVInstructionSelector::selectWaveReadLaneAt(Register ResVReg,
2014-
const SPIRVType *ResType,
2015-
MachineInstr &I) const {
2016-
return selectWaveNOpInst(ResVReg, ResType, I, SPIRV::OpGroupNonUniformShuffle,
2017-
4);
2018-
}
2019-
20201995
bool SPIRVInstructionSelector::selectBitreverse(Register ResVReg,
20211996
const SPIRVType *ResType,
20221997
MachineInstr &I) const {
@@ -2844,7 +2819,7 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg,
28442819
case Intrinsic::spv_wave_active_countbits:
28452820
return selectWaveActiveCountBits(ResVReg, ResType, I);
28462821
case Intrinsic::spv_wave_any:
2847-
return selectWaveActiveAnyTrue(ResVReg, ResType, I);
2822+
return selectWaveNOpInst(ResVReg, ResType, I, SPIRV::OpGroupNonUniformAny);
28482823
case Intrinsic::spv_wave_is_first_lane: {
28492824
SPIRVType *IntTy = GR.getOrCreateSPIRVIntegerType(32, I, TII);
28502825
return BuildMI(BB, I, I.getDebugLoc(),
@@ -2854,7 +2829,8 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg,
28542829
.addUse(GR.getOrCreateConstInt(3, I, IntTy, TII));
28552830
}
28562831
case Intrinsic::spv_wave_readlane:
2857-
return selectWaveReadLaneAt(ResVReg, ResType, I);
2832+
return selectWaveNOpInst(ResVReg, ResType, I,
2833+
SPIRV::OpGroupNonUniformShuffle);
28582834
case Intrinsic::spv_step:
28592835
return selectExtInst(ResVReg, ResType, I, CL::step, GL::Step);
28602836
case Intrinsic::spv_radians:

0 commit comments

Comments
 (0)