From: Karol Herbst <karolher...@gmail.com> helps mainly feral ported games
changes in shader-db: total instructions in shared programs : 5730139 -> 5726007 (-0.07%) total gprs used in shared programs : 663206 -> 663147 (-0.01%) total shared used in shared programs : 548832 -> 548832 (0.00%) total local used in shared programs : 20956 -> 20956 (0.00%) total bytes used in shared programs : 61212472 -> 61168408 (-0.07%) local shared gpr inst bytes helped 0 0 61 1087 1087 hurt 0 0 4 0 0 Signed-off-by: Karol Herbst <kher...@redhat.com> --- .../nouveau/codegen/nv50_ir_peephole.cpp | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp index 3a4d7e27ef7..3c1ee7f92f5 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp @@ -345,6 +345,8 @@ private: void expr(Instruction *, ImmediateValue&, ImmediateValue&); void expr(Instruction *, ImmediateValue&, ImmediateValue&, ImmediateValue&); void opnd(Instruction *, ImmediateValue&, int s); + // 3 srcs where 1st and 2nd are immediates + void opnd(Instruction *, ImmediateValue&, ImmediateValue&); void opnd3(Instruction *, ImmediateValue&); void unary(Instruction *, const ImmediateValue&); @@ -400,6 +402,10 @@ ConstantFolding::visit(BasicBlock *bb) opnd(i, src1, 1); if (i->srcExists(2) && i->src(2).getImmediate(src2)) opnd3(i, src2); + else + if (i->srcExists(2) && + i->src(0).getImmediate(src0) && i->src(1).getImmediate(src1)) + opnd(i, src0, src1); } return true; } @@ -902,6 +908,50 @@ ConstantFolding::tryCollapseChainedMULs(Instruction *mul2, } } +void +ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, ImmediateValue &imm1) +{ + const Storage &a = imm0.reg; + const Storage &b = imm1.reg; + + switch (i->op) { + case OP_SLCT: { + CmpInstruction *slct = i->asCmp(); + if (a.data.u32 == 0xffffffff && b.data.u32 == 0x0) { + slct->setSrc(0, slct->getSrc(2)); + slct->setSrc(2, NULL); + slct->dType = TYPE_U32; + slct->op = OP_SET; + } + else if (a.data.u32 == 0x3f800000 && b.data.u32 == 0x0) { + slct->setSrc(0, slct->getSrc(2)); + slct->setSrc(2, NULL); + slct->dType = TYPE_F32; + slct->op = OP_SET; + } + else if (a.data.u32 == 0x0 && b.data.u32 == 0xffffffff) { + slct->swapSources(0, 1); + slct->setSrc(0, slct->getSrc(2)); + slct->setSrc(2, NULL); + slct->dType = TYPE_U32; + slct->setCondition(inverseCondCode(slct->getCondition())); + slct->op = OP_SET; + } + else if (a.data.u32 == 0x0 && b.data.u32 == 0x3f800000) { + slct->swapSources(0, 1); + slct->setSrc(0, slct->getSrc(2)); + slct->setSrc(2, NULL); + slct->dType = TYPE_F32; + slct->setCondition(inverseCondCode(slct->getCondition())); + slct->op = OP_SET; + } + break; + } + default: + break; + } +} + void ConstantFolding::opnd3(Instruction *i, ImmediateValue &imm2) { -- 2.17.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev