Implement V_READFIRSTLANE_B32 (#681)

* Implement V_READFIRSTLANE_B32

* refactor
This commit is contained in:
Grégoire Hage 2024-09-01 20:49:42 +02:00 committed by GitHub
parent e4d8857eb5
commit 1bd9317509
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 4 deletions

View file

@ -23,7 +23,7 @@ Id EmitQuadShuffle(EmitContext& ctx, Id value, Id index) {
}
Id EmitReadFirstLane(EmitContext& ctx, Id value) {
UNREACHABLE();
return ctx.OpGroupNonUniformBroadcastFirst(ctx.U32[1], SubgroupScope(ctx), value);
}
Id EmitReadLane(EmitContext& ctx, Id value, u32 lane) {

View file

@ -167,8 +167,14 @@ void Translator::S_BARRIER() {
}
void Translator::V_READFIRSTLANE_B32(const GcnInst& inst) {
ASSERT(info.stage != Stage::Compute);
SetDst(inst.dst[0], GetSrc(inst.src[0]));
const IR::ScalarReg dst{inst.dst[0].code};
const IR::U32 value{GetSrc(inst.src[0])};
if (info.stage != Stage::Compute) {
ir.SetScalarReg(dst, value);
} else {
ir.SetScalarReg(dst, ir.ReadFirstLane(value));
}
}
void Translator::V_READLANE_B32(const GcnInst& inst) {

View file

@ -340,6 +340,6 @@ OPCODE(ImageAtomicExchange32, U32, Opaq
OPCODE(LaneId, U32, )
OPCODE(WarpId, U32, )
OPCODE(QuadShuffle, U32, U32, U32 )
OPCODE(ReadFirstLane, U32, U32, U32 )
OPCODE(ReadFirstLane, U32, U32, )
OPCODE(ReadLane, U32, U32, U32 )
OPCODE(WriteLane, U32, U32, U32, U32 )