On Monday, August 18, 2014 12:24:14 PM Matt Turner wrote: > total instructions in shared programs: 4344280 -> 4288033 (-1.29%) > instructions in affected programs: 397468 -> 341221 (-14.15%) > --- > Suggestions for a better name are welcome.
I like the name. > > src/mesa/drivers/dri/i965/brw_vec4.cpp | 98 > ++++++++++++++++++++++++++++++++++ > src/mesa/drivers/dri/i965/brw_vec4.h | 1 + > 2 files changed, 99 insertions(+) > > diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp > b/src/mesa/drivers/dri/i965/brw_vec4.cpp > index 5d4a92c..c1363ca 100644 > --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp > +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp > @@ -311,6 +311,103 @@ src_reg::equals(const src_reg &r) const > sizeof(fixed_hw_reg)) == 0); > } > > +/* Replaces unused channels of a swizzle with channels that are used. > + * > + * For instance, this pass transforms > + * > + * mov vgrf4.yz, vgrf5.wxzy > + * > + * into > + * > + * mov vgrf4.yz, vgrf5.xxzx > + * > + * This eliminates false uses of some channels, letting dead code elimination > + * remove the instructions that wrote them. > + */ > +bool > +vec4_visitor::opt_reduce_swizzle() > +{ > + bool progress = false; > + > + foreach_in_list_safe(vec4_instruction, inst, &instructions) { > + if (inst->dst.file == BAD_FILE || inst->dst.file == HW_REG) > + continue; > + > + int swizzle[4]; > + > + /* Determine which channels of the sources are read. */ > + switch (inst->opcode) { > + case BRW_OPCODE_DP4: > + case BRW_OPCODE_DPH: /* FINISHME: DPH reads only three channels of > src0, > + * but all four of src1. > + */ > + swizzle[0] = 0; > + swizzle[1] = 1; > + swizzle[2] = 2; > + swizzle[3] = 3; > + break; > + case BRW_OPCODE_DP3: > + swizzle[0] = 0; > + swizzle[1] = 1; > + swizzle[2] = 2; > + swizzle[3] = -1; > + break; > + case BRW_OPCODE_DP2: > + swizzle[0] = 0; > + swizzle[1] = 1; > + swizzle[2] = -1; > + swizzle[3] = -1; > + break; > + default: > + swizzle[0] = inst->dst.writemask & WRITEMASK_X ? 0 : -1; > + swizzle[1] = inst->dst.writemask & WRITEMASK_Y ? 1 : -1; > + swizzle[2] = inst->dst.writemask & WRITEMASK_Z ? 2 : -1; > + swizzle[3] = inst->dst.writemask & WRITEMASK_W ? 3 : -1; > + break; > + } > + > + /* Resolve unread channels (-1) by assigning them the swizzle of the > + * first channel that is used. > + */ > + int chosen = 0; Perhaps "int first_used_channel = 0;"? Either way, this patch is: Reviewed-by: Kenneth Graunke <kenn...@whitecape.org> Great work! :)
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev