[Mesa-dev] [PATCH 6/6] ir_to_mesa: Try to avoid emitting a MOV_SAT to saturate an expression tree.
Ian Romanick
idr at freedesktop.org
Mon Aug 1 10:50:41 PDT 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 07/29/2011 12:48 PM, Eric Anholt wrote:
> Fixes a regression in codegen quality for ff_fragment_shader
> conversion to GLSL -- glean texCombine produces 7.5% fewer Mesa IR
> instructions.
> ---
> src/mesa/program/ir_to_mesa.cpp | 28 ++++++++++++++++++++++++----
> 1 files changed, 24 insertions(+), 4 deletions(-)
>
> diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
> index 8b4a535..f82b048 100644
> --- a/src/mesa/program/ir_to_mesa.cpp
> +++ b/src/mesa/program/ir_to_mesa.cpp
> @@ -925,13 +925,33 @@ ir_to_mesa_visitor::try_emit_sat(ir_expression *ir)
> if (!sat_src)
> return false;
>
> + ir_to_mesa_instruction *new_inst;
> +
Why not move this declaration down to the one place new_inst is set?
> sat_src->accept(this);
> src_reg src = this->result;
>
> - this->result = get_temp(ir->type);
> - ir_to_mesa_instruction *inst;
> - inst = emit(ir, OPCODE_MOV, dst_reg(this->result), src);
> - inst->saturate = true;
> + /* If we generated an expression instruction into a temporary in
> + * processing the saturate's operand, apply the saturate to that
> + * instruction. Otherwise, generate a MOV to do the saturate.
> + *
> + * Note that we have to be careful to only do this optimization if
> + * the instruction in question was in generating src->result -- for
> + * example, ir_dereference_array would generate a MUL to create the
> + * reladdr and return us a src reg using that reladdr, and that MUL
> + * not the thing we're trying to saturate.
The "and that MUL.." bit doesn't parse for me.
> + */
> + ir_expression *sat_src_expr = sat_src->as_expression();
> + new_inst = (ir_to_mesa_instruction *)this->instructions.get_tail();
> + if (sat_src_expr && (sat_src_expr->operation == ir_binop_mul ||
> + sat_src_expr->operation == ir_binop_add ||
> + sat_src_expr->operation == ir_binop_dot)) {
> + new_inst->saturate = true;
> + } else {
> + this->result = get_temp(ir->type);
> + ir_to_mesa_instruction *inst;
> + inst = emit(ir, OPCODE_MOV, dst_reg(this->result), src);
> + inst->saturate = true;
> + }
>
> return true;
> }
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAk4253EACgkQX1gOwKyEAw+v8wCdEYODs+zLOoHkv1H1xmoU3UMX
NPkAoIXJCEAbKy/6F9lZFwvrArwVMHCc
=DJ3g
-----END PGP SIGNATURE-----
More information about the mesa-dev
mailing list