changes for GpuTest /test=pixmark_piano /benchmark /no_scorebox /msaa=0 /benchmark_duration_ms=60000 /width=1024 /height=640:
score: 1026 -> 1046 changes for shader-db: total instructions in shared programs : 2752260 -> 2742049 (-0.37%) total gprs used in shared programs : 380557 -> 380557 (0.00%) total local used in shared programs : 9389 -> 9389 (0.00%) total bytes used in shared programs : 22018080 -> 21936392 (-0.37%) local gpr inst bytes helped 0 0 4063 4063 hurt 0 0 0 0 Signed-off-by: Karol Herbst <karolher...@gmail.com> --- .../drivers/nouveau/codegen/nv50_ir_peephole.cpp | 65 ++++++++++++++++++++-- 1 file changed, 60 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp index f2ada55..3c660f3 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp @@ -2956,13 +2956,14 @@ class PostRaConstantFolding : public Pass { private: virtual bool visit(Instruction *); - void handleMAD(Instruction *); + void handleMADforNV50(Instruction *); + void handleMADforNVC0(Instruction *); }; // Fold Immediate into MAD; must be done after register allocation due to // constraint SDST == SSRC2 void -PostRaConstantFolding::handleMAD(Instruction *i) +PostRaConstantFolding::handleMADforNV50(Instruction *i) { if (i->def(0).getFile() != FILE_GPR || i->src(0).getFile() != FILE_GPR || @@ -3015,12 +3016,67 @@ PostRaConstantFolding::handleMAD(Instruction *i) } } +void +PostRaConstantFolding::handleMADforNVC0(Instruction *i) +{ + if (i->def(0).getFile() != FILE_GPR || + i->src(0).getFile() != FILE_GPR || + i->src(1).getFile() != FILE_GPR || + i->src(2).getFile() != FILE_GPR || + i->getDef(0)->reg.data.id != i->getSrc(2)->reg.data.id) + return; + + int chipset = prog->getTarget()->getChipset(); + if (i->getPredicate()) { + // prior gk110 we can't do that if we have a predicate + if (chipset < NVISA_GK20A_CHIPSET) + return; + // and gk110 can't handle a cc + if (chipset < NVISA_GM107_CHIPSET && i->cc) + return; + } + + // TODO: gm107 can also do this for S32 + if (i->dType != TYPE_F32) + return; + + if ((i->src(2).mod | Modifier(NV50_IR_MOD_NEG)) != Modifier(NV50_IR_MOD_NEG)) + return; + + ImmediateValue val; + int s; + + if (i->src(0).getImmediate(val)) + s = 1; + else if (i->src(1).getImmediate(val)) + s = 0; + else + return; + + if ((i->src(s).mod | Modifier(NV50_IR_MOD_NEG)) != Modifier(NV50_IR_MOD_NEG)) + return; + + if ((i->src(s ^ 1).mod | Modifier(NV50_IR_MOD_NEG)) != Modifier(NV50_IR_MOD_NEG)) + i->print(); + + if (s == 1) + i->swapSources(0, 1); + + Instruction *imm = i->getSrc(1)->getInsn(); + i->setSrc(1, imm->getSrc(0)); + if (imm->isDead(true)) + delete_Instruction(prog, imm); +} + bool PostRaConstantFolding::visit(Instruction *i) { switch (i->op) { case OP_MAD: - handleMAD(i); + if (prog->getTarget()->getChipset() < 0xc0) + handleMADforNV50(i); + else + handleMADforNVC0(i); break; default: break; @@ -3554,8 +3610,7 @@ bool Program::optimizePostRA(int level) { RUN_PASS(2, FlatteningPass, run); - if (getTarget()->getChipset() < 0xc0) - RUN_PASS(2, PostRaConstantFolding, run); + RUN_PASS(2, PostRaConstantFolding, run); return true; } -- 2.10.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev