[Mesa-dev] [PATCH] nv50/ir: optimise slct(t, f, set) to mov(set) or not(set)
Karol Herbst
kherbst at redhat.com
Tue Mar 27 22:35:09 UTC 2018
just noticed I sent out the wrong version of that patch...
On Tue, Mar 27, 2018 at 10:50 PM, Karol Herbst <kherbst at redhat.com> wrote:
> From: Karol Herbst <karolherbst at gmail.com>
>
> helps mainly Feral-ported games
>
> changes in shader-db:
> total instructions in shared programs : 3940749 -> 3935015 (-0.15%)
> total gprs used in shared programs : 481460 -> 481433 (-0.01%)
> total local used in shared programs : 27481 -> 27513 (0.12%)
> total bytes used in shared programs : 36115776 -> 36063344 (-0.15%)
>
> local gpr inst bytes
> helped 6 31 854 854
> hurt 10 5 1 1
> ---
> .../drivers/nouveau/codegen/nv50_ir_peephole.cpp | 26 ++++++++++++++++++++--
> 1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> index 48cf74950df..1e3dea95494 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> @@ -637,9 +637,31 @@ ConstantFolding::expr(Instruction *i,
> }
> break;
> case OP_SLCT:
> - if (a->data.u32 != b->data.u32)
> + // slct(a, a, b) -> a
> + if (a->data.u32 == b->data.u32) {
> + res.data.u32 = a->data.u32;
> + } else {
> + // slct_ne(true, false, bool) -> !bool
> + CmpInstruction *slct = i->asCmp();
> + Instruction *set = i->getSrc(2)->getInsn();
> + if (!set || set->op != OP_SET)
> + return;
> + if (isFloatType(set->dType))
> + return;
> + if ((slct->getCondition() == CC_NE && imm0.isInteger(-1) && imm1.isInteger(0)) ||
> + (slct->getCondition() == CC_EQ && imm0.isInteger(0) && imm1.isInteger(-1))) {
> + bld.setPosition(i, false);
> + bld.mkOp1(OP_MOV, i->dType, i->getDef(0), i->getSrc(2));
> + delete_Instruction(prog, i);
> + } else if (
> + (slct->getCondition() == CC_EQ && imm0.isInteger(-1) && imm1.isInteger(0)) ||
> + (slct->getCondition() == CC_NE && imm0.isInteger(0) && imm1.isInteger(-1))) {
> + bld.setPosition(i, false);
> + bld.mkOp1(OP_NOT, i->dType, i->getDef(0), i->getSrc(2));
> + delete_Instruction(prog, i);
> + }
> return;
> - res.data.u32 = a->data.u32;
> + }
> break;
> case OP_EXTBF: {
> int offset = b->data.u32 & 0xff;
> --
> 2.14.3
>
More information about the mesa-dev
mailing list