[Mesa-dev] [PATCH 2/7] i965: Update JIP/UIP compaction code to operate on bytes.

Kenneth Graunke kenneth at whitecape.org
Mon Aug 18 14:47:04 PDT 2014


On Monday, August 18, 2014 11:19:48 AM Matt Turner wrote:
> JIP/UIP were previously in units of compacted instructions. On Gen8
> they're in units of bytes.
> ---
>  src/mesa/drivers/dri/i965/brw_eu_compact.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_eu_compact.c b/src/mesa/drivers/dri/i965/brw_eu_compact.c
> index 25a96e7..f100297 100644
> --- a/src/mesa/drivers/dri/i965/brw_eu_compact.c
> +++ b/src/mesa/drivers/dri/i965/brw_eu_compact.c
> @@ -653,17 +653,19 @@ static void
>  update_uip_jip(struct brw_context *brw, brw_inst *insn,
>                 int this_old_ip, int *compacted_counts)
>  {
> -   int jip = brw_inst_jip(brw, insn);
> +   int scale = brw->gen >= 8 ? sizeof(brw_compact_inst) : 1;
> +
> +   int32_t jip = brw_inst_jip(brw, insn) / scale;
>     jip -= compacted_between(this_old_ip, this_old_ip + jip, compacted_counts);
> -   brw_inst_set_jip(brw, insn, jip);
> +   brw_inst_set_jip(brw, insn, jip * scale);
>  
>     if (brw_inst_opcode(brw, insn) == BRW_OPCODE_ENDIF ||
>         brw_inst_opcode(brw, insn) == BRW_OPCODE_WHILE)
>        return;
>  
> -   int uip = brw_inst_uip(brw, insn);
> +   int32_t uip = brw_inst_uip(brw, insn) / scale;
>     uip -= compacted_between(this_old_ip, this_old_ip + uip, compacted_counts);
> -   brw_inst_set_uip(brw, insn, uip);
> +   brw_inst_set_uip(brw, insn, uip * scale);
>  }
>  
>  void
> 

This originally confused me a bit, but I believe it's correct.
Here, your local variable jip is the jump distance in units of "number of compact instructions".  So, for Broadwell, you convert from bytes to that, subtract some number of compact instructions, and scale back up.

You could instead do:

   int32_t jip = brw_inst_jip(brw, insn);
   jip -= scale *
      compacted_between(this_old_ip, this_old_ip + jip, compacted_counts);
   brw_inst_set_jip(brw, insn, jip);

which is a bit less frobbing around and unit conversions.

You could also do:

   int scale = brw_jump_scale(brw) / 2;

if you wanted.  I'll leave it up to you which style you prefer.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140818/90ed200e/attachment.sig>


More information about the mesa-dev mailing list