<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, May 27, 2016 at 7:05 PM, Francisco Jerez <span dir="ltr"><<a href="mailto:currojerez@riseup.net" target="_blank">currojerez@riseup.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This will be useful in several places. The only externally visible<br>
difference (other than non-VGRF files being supported now) is that the<br>
region sizes are now passed in byte units instead of in GRF units<br>
because the loss of precision would have become a problem in the SIMD<br>
lowering pass.<br>
---<br>
.../drivers/dri/i965/brw_fs_copy_propagation.cpp | 16 +++------<br>
src/mesa/drivers/dri/i965/brw_ir_fs.h | 38 ++++++++++++++++++++++<br>
2 files changed, 42 insertions(+), 12 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp<br>
index 38103af..d88d62b 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp<br>
@@ -757,14 +757,6 @@ can_propagate_from(fs_inst *inst)<br>
!inst->is_partial_write());<br>
}<br>
<br>
-inline bool<br>
-regions_overlap(const fs_reg &r, unsigned n, const fs_reg &s, unsigned m)<br>
-{<br>
- return r.file == s.file && <a href="http://r.nr" rel="noreferrer" target="_blank">r.nr</a> == <a href="http://s.nr" rel="noreferrer" target="_blank">s.nr</a> &&<br>
- !(r.reg_offset + n <= s.reg_offset ||<br>
- s.reg_offset + m <= r.reg_offset);<br>
-}<br>
-<br>
/* Walks a basic block and does copy propagation on it using the acp<br>
* list.<br>
*/<br>
@@ -791,8 +783,8 @@ fs_visitor::opt_copy_propagate_local(void *copy_prop_ctx, bblock_t *block,<br>
/* kill the destination from the ACP */<br>
if (inst->dst.file == VGRF) {<br>
foreach_in_list_safe(acp_entry, entry, &acp[inst-><a href="http://dst.nr" rel="noreferrer" target="_blank">dst.nr</a> % ACP_HASH_SIZE]) {<br>
- if (regions_overlap(entry->dst, entry->regs_written,<br>
- inst->dst, inst->regs_written))<br>
+ if (regions_overlap(entry->dst, entry->regs_written * REG_SIZE,<br>
+ inst->dst, inst->regs_written * REG_SIZE))<br>
entry->remove();<br>
}<br>
<br>
@@ -804,8 +796,8 @@ fs_visitor::opt_copy_propagate_local(void *copy_prop_ctx, bblock_t *block,<br>
/* Make sure we kill the entry if this instruction overwrites<br>
* _any_ of the registers that it reads<br>
*/<br>
- if (regions_overlap(entry->src, entry->regs_read,<br>
- inst->dst, inst->regs_written))<br>
+ if (regions_overlap(entry->src, entry->regs_read * REG_SIZE,<br>
+ inst->dst, inst->regs_written * REG_SIZE))<br>
entry->remove();<br>
}<br>
}<br>
diff --git a/src/mesa/drivers/dri/i965/brw_ir_fs.h b/src/mesa/drivers/dri/i965/brw_ir_fs.h<br>
index cc1561d..73c6327 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_ir_fs.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_ir_fs.h<br>
@@ -172,6 +172,44 @@ component(fs_reg reg, unsigned idx)<br>
}<br>
<br>
/**<br>
+ * Return an integer identifying the discrete address space a register is<br>
+ * contained in. A register is by definition fully contained in the single<br>
+ * reg_space it belongs to, so two registers with different reg_space ids are<br>
+ * guaranteed not to overlap. Most register files are a single reg_space of<br>
+ * its own, only the VGRF file is composed of multiple discrete address<br>
+ * spaces, one for each VGRF allocation.<br>
+ */<br>
+static inline uint32_t<br>
+reg_space(const fs_reg &r)<br>
+{<br>
+ return r.file << 16 | (r.file == VGRF ? <a href="http://r.nr" rel="noreferrer" target="_blank">r.nr</a> : 0);<br>
+}<br></blockquote><div><br></div><div>I think I like this concept. It would lead to a bit more compact numbering if you did "return r.file == VGRF ? <a href="http://r.nr">r.nr</a> + 8 : r.file". Obviously, you would probably want to replace "8" with a BRW_NUM_REG_FILES constant.<br><br></div><div>Given that we really only care about reg_space(r) == reg_space(s) right now, this is fine.<br><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+/**<br>
+ * Return the base offset in bytes of a register relative to the start of its<br>
+ * reg_space().<br>
+ */<br>
+static inline unsigned<br>
+reg_offset(const fs_reg &r)<br>
+{<br>
+ return ((r.file == VGRF || r.file == IMM ? 0 : <a href="http://r.nr" rel="noreferrer" target="_blank">r.nr</a>) + r.reg_offset) *<br>
+ (r.file == UNIFORM ? 4 : REG_SIZE) + r.subreg_offset;<br>
+}<br>
+<br>
+/**<br>
+ * Return whether the register region starting at \p r and spanning \p dr<br>
+ * bytes could potentially overlap the register region starting at \p s and<br>
+ * spanning \p ds bytes.<br>
+ */<br>
+static inline bool<br>
+regions_overlap(const fs_reg &r, unsigned dr, const fs_reg &s, unsigned ds)<br>
+{<br>
+ return reg_space(r) == reg_space(s) &&<br>
+ !(reg_offset(r) + dr <= reg_offset(s) ||<br>
+ reg_offset(s) + ds <= reg_offset(r));<br>
+}<br>
+<br>
+/**<br>
* Return whether the given register region is n-periodic, i.e. whether the<br>
* original region remains invariant after shifting it by \p n scalar<br>
* channels.<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.7.3<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="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>