gv100/ir: fix shift lowering

Wrap was ignored. Also merge functions to share code.

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5576>
This commit is contained in:
Karol Herbst
2020-06-20 16:52:44 +02:00
parent a5445010e4
commit 42b9aa5f5c
2 changed files with 19 additions and 21 deletions

View File

@@ -206,24 +206,25 @@ GV100LegalizeSSA::handleSHFL(Instruction *i)
} }
bool bool
GV100LegalizeSSA::handleSHL(Instruction *i) GV100LegalizeSSA::handleShift(Instruction *i)
{ {
if (i->src(0).getFile() != FILE_GPR) { Value *zero = bld.mkImm(0);
bld.mkOp3(OP_SHF, i->dType, i->getDef(0), bld.mkImm(0), i->getSrc(1), Value *src1 = i->getSrc(1);
i->getSrc(0))->subOp = NV50_IR_SUBOP_SHF_L | Value *src0, *src2;
NV50_IR_SUBOP_SHF_HI; uint8_t subOp = i->op == OP_SHL ? NV50_IR_SUBOP_SHF_L : NV50_IR_SUBOP_SHF_R;
} 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;
}
return true;
}
bool if (i->op == OP_SHL && i->src(0).getFile() == FILE_GPR) {
GV100LegalizeSSA::handleSHR(Instruction *i) src0 = i->getSrc(0);
{ src2 = zero;
bld.mkOp3(OP_SHF, i->dType, i->getDef(0), bld.mkImm(0), i->getSrc(1), } else {
i->getSrc(0))->subOp = NV50_IR_SUBOP_SHF_R | NV50_IR_SUBOP_SHF_HI; src0 = zero;
src2 = i->getSrc(0);
subOp |= NV50_IR_SUBOP_SHF_HI;
}
if (i->subOp & NV50_IR_SUBOP_SHIFT_WRAP)
subOp |= NV50_IR_SUBOP_SHF_W;
bld.mkOp3(OP_SHF, i->dType, i->getDef(0), src0, src1, src2)->subOp = subOp;
return true; return true;
} }
@@ -255,10 +256,8 @@ GV100LegalizeSSA::visit(Instruction *i)
lowered = handleNOT(i); lowered = handleNOT(i);
break; break;
case OP_SHL: case OP_SHL:
lowered = handleSHL(i);
break;
case OP_SHR: case OP_SHR:
lowered = handleSHR(i); lowered = handleShift(i);
break; break;
case OP_SET: case OP_SET:
case OP_SET_AND: case OP_SET_AND:

View File

@@ -71,8 +71,7 @@ private:
bool handleQUADPOP(Instruction *); bool handleQUADPOP(Instruction *);
bool handleSET(Instruction *); bool handleSET(Instruction *);
bool handleSHFL(Instruction *); bool handleSHFL(Instruction *);
bool handleSHL(Instruction *); bool handleShift(Instruction *);
bool handleSHR(Instruction *);
bool handleSUB(Instruction *); bool handleSUB(Instruction *);
}; };
} }