Mesa (master): glsl: Use bitfieldInsert in ldexp() lowering.

Matt Turner mattst88 at kemper.freedesktop.org
Tue Jan 28 05:18:51 UTC 2014


Module: Mesa
Branch: master
Commit: 57109d57f8c7425f4c6f865f1697a864da27aabd
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=57109d57f8c7425f4c6f865f1697a864da27aabd

Author: Matt Turner <mattst88 at gmail.com>
Date:   Mon Jan 27 11:56:14 2014 -0800

glsl: Use bitfieldInsert in ldexp() lowering.

Shaves a few instructions off of lowered ldexp().

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/glsl/lower_instructions.cpp |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/glsl/lower_instructions.cpp b/src/glsl/lower_instructions.cpp
index 8f8d448..44a6e80 100644
--- a/src/glsl/lower_instructions.cpp
+++ b/src/glsl/lower_instructions.cpp
@@ -384,10 +384,10 @@ lower_instructions_visitor::ldexp_to_arith(ir_expression *ir)
    /* Constants */
    ir_constant *zeroi = ir_constant::zero(ir, ivec);
 
-   ir_constant *sign_mantissa_mask = new(ir) ir_constant(0x807fffffu, vec_elem);
    ir_constant *sign_mask = new(ir) ir_constant(0x80000000u, vec_elem);
 
    ir_constant *exp_shift = new(ir) ir_constant(23u, vec_elem);
+   ir_constant *exp_width = new(ir) ir_constant(8u, vec_elem);
 
    /* Temporary variables */
    ir_variable *x = new(ir) ir_variable(ir->type, "x", ir_var_temporary);
@@ -449,11 +449,17 @@ lower_instructions_visitor::ldexp_to_arith(ir_expression *ir)
     */
 
    ir_constant *exp_shift_clone = exp_shift->clone(ir, NULL);
-   ir->operation = ir_unop_bitcast_u2f;
-   ir->operands[0] = bit_or(bit_and(bitcast_f2u(x), sign_mantissa_mask),
-                            lshift(i2u(resulting_biased_exp), exp_shift_clone));
+   ir->operation = ir_unop_bitcast_i2f;
+   ir->operands[0] = bitfield_insert(bitcast_f2i(x), resulting_biased_exp,
+                                     exp_shift_clone, exp_width);
    ir->operands[1] = NULL;
 
+   /* Don't generate new IR that would need to be lowered in an additional
+    * pass.
+    */
+   if (lowering(BITFIELD_INSERT_TO_BFM_BFI))
+      bitfield_insert_to_bfm_bfi(ir->operands[0]->as_expression());
+
    this->progress = true;
 }
 




More information about the mesa-commit mailing list