<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 28, 2014 at 8:10 PM, Matt Turner <span dir="ltr"><<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The array was previously indexed in units of brw_compact_inst (8-bytes),<br>
but before compaction all instructions are uncompacted, so every odd<br>
element was unused.<br>
---<br>
src/mesa/drivers/dri/i965/brw_eu_compact.c | 59 +++++++++++++++++++-----------<br>
1 file changed, 37 insertions(+), 22 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_eu_compact.c b/src/mesa/drivers/dri/i965/brw_eu_compact.c<br>
index c291f96..acce663 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_eu_compact.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_eu_compact.c<br>
@@ -1033,20 +1033,32 @@ static void<br>
update_uip_jip(struct brw_context *brw, brw_inst *insn,<br>
int this_old_ip, int *compacted_counts)<br>
{<br>
- int scale = brw->gen >= 8 ? sizeof(brw_compact_inst) : 1;<br>
-<br>
- int32_t jip = brw_inst_jip(brw, insn) / scale;<br>
- jip -= compacted_between(this_old_ip, this_old_ip + jip, compacted_counts);<br>
- brw_inst_set_jip(brw, insn, jip * scale);<br>
+ /* JIP and UIP are in units of:<br>
+ * - bytes on Gen8+; and<br>
+ * - compacted instructions on Gen6+.<br>
+ */<br>
+ int32_t jip = brw_inst_jip(brw, insn);<br>
+ int32_t jip_compacted = jip / (brw->gen >= 8 ? sizeof(brw_compact_inst) : 1);<br>
+ int32_t jip_uncompacted = jip / (brw->gen >= 8 ? sizeof(brw_inst) : 2);<br>
+ jip_compacted -= compacted_between(this_old_ip,<br>
+ this_old_ip + jip_uncompacted,<br>
+ compacted_counts);<br></blockquote><div><br></div><div>Is this correct on gen >= 8? It seems as if you would be missing a factor of sizeof(brw_compact_inst). In general, this and the hunk below it seem very fragile. Can we do these calculations without the gen >= 8 specific stuff and then do the factor of 8 at the end?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ brw_inst_set_jip(brw, insn,<br>
+ jip_compacted * (brw->gen >= 8 ? sizeof(brw_inst) : 1));<br>
<br>
if (brw_inst_opcode(brw, insn) == BRW_OPCODE_ENDIF ||<br>
brw_inst_opcode(brw, insn) == BRW_OPCODE_WHILE ||<br>
(brw_inst_opcode(brw, insn) == BRW_OPCODE_ELSE && brw->gen <= 7))<br>
return;<br>
<br>
- int32_t uip = brw_inst_uip(brw, insn) / scale;<br>
- uip -= compacted_between(this_old_ip, this_old_ip + uip, compacted_counts);<br>
- brw_inst_set_uip(brw, insn, uip * scale);<br>
+ int32_t uip = brw_inst_uip(brw, insn);<br>
+ int32_t uip_compacted = uip / (brw->gen >= 8 ? sizeof(brw_compact_inst) : 1);<br>
+ int32_t uip_uncompacted = uip / (brw->gen >= 8 ? sizeof(brw_inst) : 2);<br>
+ uip_compacted -= compacted_between(this_old_ip,<br>
+ this_old_ip + uip_uncompacted,<br>
+ compacted_counts);<br>
+ brw_inst_set_uip(brw, insn,<br>
+ uip_compacted * (brw->gen >= 8 ? sizeof(brw_inst) : 1));<br>
}<br>
<br>
void<br>
@@ -1095,12 +1107,12 @@ brw_compact_instructions(struct brw_compile *p, int start_offset,<br>
{<br>
struct brw_context *brw = p->brw;<br>
void *store = p->store + start_offset / 16;<br>
- /* For an instruction at byte offset 8*i before compaction, this is the number<br>
- * of compacted instructions that preceded it.<br>
+ /* For an instruction at byte offset 16*i before compaction, this is the<br>
+ * number of compacted instructions that preceded it.<br>
*/<br>
- int compacted_counts[(p->next_insn_offset - start_offset) / sizeof(brw_compact_inst)];<br>
- /* For an instruction at byte offset 8*i after compaction, this is the<br>
- * 8-byte offset it was at before compaction.<br>
+ int compacted_counts[(p->next_insn_offset - start_offset) / sizeof(brw_inst)];<br>
+ /* For an instruction at byte offset 8*i after compaction, this was its IP<br>
+ * (in 16-byte units) before compaction.<br>
*/<br>
int old_ip[(p->next_insn_offset - start_offset) / sizeof(brw_compact_inst)];<br>
<br>
@@ -1114,8 +1126,8 @@ brw_compact_instructions(struct brw_compile *p, int start_offset,<br>
brw_inst *src = store + src_offset;<br>
void *dst = store + offset;<br>
<br>
- old_ip[offset / sizeof(brw_compact_inst)] = src_offset / sizeof(brw_compact_inst);<br>
- compacted_counts[src_offset / sizeof(brw_compact_inst)] = compacted_count;<br>
+ old_ip[offset / sizeof(brw_compact_inst)] = src_offset / sizeof(brw_inst);<br>
+ compacted_counts[src_offset / sizeof(brw_inst)] = compacted_count;<br>
<br>
brw_inst saved = *src;<br>
<br>
@@ -1144,7 +1156,7 @@ brw_compact_instructions(struct brw_compile *p, int start_offset,<br>
brw_compact_inst_set_opcode(align, BRW_OPCODE_NOP);<br>
brw_compact_inst_set_cmpt_control(align, true);<br>
offset += sizeof(brw_compact_inst);<br>
- old_ip[offset / sizeof(brw_compact_inst)] = src_offset / sizeof(brw_compact_inst);<br>
+ old_ip[offset / sizeof(brw_compact_inst)] = src_offset / sizeof(brw_inst);<br>
<br>
dst = store + offset;<br>
}<br>
@@ -1182,11 +1194,14 @@ brw_compact_instructions(struct brw_compile *p, int start_offset,<br>
if (brw->gen >= 7) {<br>
update_uip_jip(brw, insn, this_old_ip, compacted_counts);<br>
} else if (brw->gen == 6) {<br>
- int gen6_jump_count = brw_inst_gen6_jump_count(brw, insn);<br>
- target_old_ip = this_old_ip + gen6_jump_count;<br>
+ /* Jump Count is in units of compacted instructions on Gen6. */<br>
+ int jump_count_compacted = brw_inst_gen6_jump_count(brw, insn);<br>
+ int jump_count_uncompacted = jump_count_compacted / 2;<br>
+<br>
+ target_old_ip = this_old_ip + jump_count_uncompacted;<br>
target_compacted_count = compacted_counts[target_old_ip];<br>
- gen6_jump_count -= (target_compacted_count - this_compacted_count);<br>
- brw_inst_set_gen6_jump_count(brw, insn, gen6_jump_count);<br>
+ jump_count_compacted -= (target_compacted_count - this_compacted_count);<br>
+ brw_inst_set_gen6_jump_count(brw, insn, jump_count_compacted);<br>
}<br>
break;<br>
}<br>
@@ -1210,9 +1225,9 @@ brw_compact_instructions(struct brw_compile *p, int start_offset,<br>
if (annotation) {<br>
for (int offset = 0, i = 0; i < num_annotations; i++) {<br>
while (start_offset + old_ip[offset / sizeof(brw_compact_inst)] *<br>
- sizeof(brw_compact_inst) != annotation[i].offset) {<br>
+ sizeof(brw_inst) != annotation[i].offset) {<br>
assert(start_offset + old_ip[offset / sizeof(brw_compact_inst)] *<br>
- sizeof(brw_compact_inst) < annotation[i].offset);<br>
+ sizeof(brw_inst) < annotation[i].offset);<br>
offset = next_offset(brw, store, offset);<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
1.8.5.5<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>