From: Karol Herbst Date: Sat, 20 Jun 2020 14:52:44 +0000 (+0200) Subject: gv100/ir: fix shift lowering X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=42b9aa5f5c77390c88b17b226982a27bd1dd6c7e;p=mesa.git gv100/ir: fix shift lowering Wrap was ignored. Also merge functions to share code. Signed-off-by: Karol Herbst Reviewed-by: Ben Skeggs Part-of: --- diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gv100.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gv100.cpp index 4b6df0db588..953f082a06a 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gv100.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gv100.cpp @@ -206,24 +206,25 @@ GV100LegalizeSSA::handleSHFL(Instruction *i) } bool -GV100LegalizeSSA::handleSHL(Instruction *i) +GV100LegalizeSSA::handleShift(Instruction *i) { - if (i->src(0).getFile() != FILE_GPR) { - bld.mkOp3(OP_SHF, i->dType, i->getDef(0), bld.mkImm(0), i->getSrc(1), - i->getSrc(0))->subOp = NV50_IR_SUBOP_SHF_L | - NV50_IR_SUBOP_SHF_HI; + Value *zero = bld.mkImm(0); + Value *src1 = i->getSrc(1); + Value *src0, *src2; + uint8_t subOp = i->op == OP_SHL ? NV50_IR_SUBOP_SHF_L : NV50_IR_SUBOP_SHF_R; + + if (i->op == OP_SHL && i->src(0).getFile() == FILE_GPR) { + src0 = i->getSrc(0); + src2 = zero; } else { - bld.mkOp3(OP_SHF, i->dType, i->getDef(0), i->getSrc(0), i->getSrc(1), - bld.mkImm(0))->subOp = NV50_IR_SUBOP_SHF_L; + src0 = zero; + src2 = i->getSrc(0); + subOp |= NV50_IR_SUBOP_SHF_HI; } - return true; -} + if (i->subOp & NV50_IR_SUBOP_SHIFT_WRAP) + subOp |= NV50_IR_SUBOP_SHF_W; -bool -GV100LegalizeSSA::handleSHR(Instruction *i) -{ - bld.mkOp3(OP_SHF, i->dType, i->getDef(0), bld.mkImm(0), i->getSrc(1), - i->getSrc(0))->subOp = NV50_IR_SUBOP_SHF_R | NV50_IR_SUBOP_SHF_HI; + bld.mkOp3(OP_SHF, i->dType, i->getDef(0), src0, src1, src2)->subOp = subOp; return true; } @@ -255,10 +256,8 @@ GV100LegalizeSSA::visit(Instruction *i) lowered = handleNOT(i); break; case OP_SHL: - lowered = handleSHL(i); - break; case OP_SHR: - lowered = handleSHR(i); + lowered = handleShift(i); break; case OP_SET: case OP_SET_AND: diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gv100.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gv100.h index 92fdb938244..d918c6e83eb 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gv100.h +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_gv100.h @@ -71,8 +71,7 @@ private: bool handleQUADPOP(Instruction *); bool handleSET(Instruction *); bool handleSHFL(Instruction *); - bool handleSHL(Instruction *); - bool handleSHR(Instruction *); + bool handleShift(Instruction *); bool handleSUB(Instruction *); }; }