diff options
author | Karol Herbst <[email protected]> | 2018-03-27 19:10:34 +0200 |
---|---|---|
committer | Ilia Mirkin <[email protected]> | 2018-04-21 10:53:59 -0400 |
commit | 63572091b52ace35b60c46d092183bf818733ee0 (patch) | |
tree | 0044f18dc119a61fa0709fa0f16f1cb27854db46 /src | |
parent | cc35b76e99779e6360fdd25fb39fbf1092f938be (diff) |
nv50/ir/ra: prefer def == src2 for fma with immediates on nvc0
This helps with the PostRALoadPropagation pass moving long immediates into
FMA/MAD instructions.
changes in shader-db:
total instructions in shared programs : 5894114 -> 5886074 (-0.14%)
total gprs used in shared programs : 666558 -> 666563 (0.00%)
total shared used in shared programs : 520416 -> 520416 (0.00%)
total local used in shared programs : 53524 -> 53524 (0.00%)
total bytes used in shared programs : 54006744 -> 53932472 (-0.14%)
local shared gpr inst bytes
helped 0 0 2 4192 4192
hurt 0 0 7 9 9
Signed-off-by: Karol Herbst <[email protected]>
[imirkin: minor edits to separate nv50 and nvc0+ cases]
Reviewed-by: Ilia Mirkin <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp index 3a0e56e1385..3953475c0ac 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp @@ -1466,17 +1466,36 @@ GCRA::allocateRegisters(ArrayList& insns) nodes[i].init(regs, lval); RIG.insert(&nodes[i]); - if (lval->inFile(FILE_GPR) && lval->getInsn() != NULL && - prog->getTarget()->getChipset() < 0xc0) { + if (lval->inFile(FILE_GPR) && lval->getInsn() != NULL) { Instruction *insn = lval->getInsn(); - if (insn->op == OP_MAD || insn->op == OP_FMA || insn->op == OP_SAD) - // Short encoding only possible if they're all GPRs, no need to - // affect them otherwise. - if (insn->flagsDef < 0 && - insn->src(0).getFile() == FILE_GPR && - insn->src(1).getFile() == FILE_GPR && - insn->src(2).getFile() == FILE_GPR) - nodes[i].addRegPreference(getNode(insn->getSrc(2)->asLValue())); + if (insn->op != OP_MAD && insn->op != OP_FMA && insn->op != OP_SAD) + continue; + // For both of the cases below, we only want to add the preference + // if all arguments are in registers. + if (insn->src(0).getFile() != FILE_GPR || + insn->src(1).getFile() != FILE_GPR || + insn->src(2).getFile() != FILE_GPR) + continue; + if (prog->getTarget()->getChipset() < 0xc0) { + // Outputting a flag is not supported with short encodings nor + // with immediate arguments. + // See handleMADforNV50. + if (insn->flagsDef >= 0) + continue; + } else { + // We can only fold immediate arguments if dst == src2. This + // only matters if one of the first two arguments is an + // immediate. This form is also only supported for floats. + // See handleMADforNVC0. + ImmediateValue imm; + if (insn->dType != TYPE_F32) + continue; + if (!insn->src(0).getImmediate(imm) && + !insn->src(1).getImmediate(imm)) + continue; + } + + nodes[i].addRegPreference(getNode(insn->getSrc(2)->asLValue())); } } } |