[Mesa-dev] [PATCH 06/16] glsl: Add a pass to lower bitfield-insert into bfm+bfi.

Matt Turner mattst88 at gmail.com
Wed Apr 24 14:02:21 PDT 2013


On Tue, Apr 23, 2013 at 2:23 AM, Chris Forbes <chrisf at ijw.co.nz> wrote:
> +   /* Save op0 */
> +   ir_variable *temp = new(ir) ir_variable(ir->operands[0]->
> type, "bfi_base",
> +                                           ir_var_temporary);
> +   this->base_ir->insert_before(temp);
> +   this->base_ir->insert_before(assign(temp, ir->operands[0]));
> +
> +   ir->operation = ir_triop_bfi;
> +   ir->operands[0] = new(ir) ir_expression(ir_binop_bfm, ir->type,
> +                                           swizzle_xxxx(ir->operands[3]),
> +                                           swizzle_xxxx(ir->operands[2]));
> +   /* ir->operands[1] is still the value to insert. */
> +   ir->operands[2] = new(ir) ir_dereference_variable(temp);
> +   ir->operands[3] = NULL;
>
> Emitting the temp and assignment to it into the IR seems spurious --
> is there a reason something like this doesn't work:?
>
>     ir_rvalue *base_expr = ir->operands[0];
>     ir->operation = ir_triop_bfi;
>     ir->operands[0] = new(ir) ir_expression(ir_binop_bfm, ir-type,
>                                             swizzle_xxxx(ir->operands[3]),
>                                             swizzle_xxxx(ir->operands[2]));
>     /* ir->operands[1] is still the value to insert. */
>     ir->operands[2] = base_expr;
>     ir->operands[3] = NULL;
>
> I might have missed something :)
>
> -- Chris

Yes, that is much simpler. I'd just copied the lrp_to_arith function
to begin with, but it actually has a reason to create a temporary and
do the assignment: it uses the temporary multiple times.


More information about the mesa-dev mailing list