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

Chris Forbes chrisf at ijw.co.nz
Tue Apr 23 02:23:29 PDT 2013


+   /* 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


More information about the mesa-dev mailing list