<div dir="ltr">On 2 December 2013 11:31, Francisco Jerez <span dir="ltr"><<a href="mailto:currojerez@riseup.net" target="_blank">currojerez@riseup.net</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Add assertion that the register is not in the HW_REG or IMM file,<br>
calculate the conjunction of the old and new mask instead of replacing<br>
the old [consistent with the behavior of brw_writemask(), causes no<br>
functional changes right now], make it static inline to let the<br>
compiler do a slightly better job at optimizing things, and shorten<br>
its name.<br>
---<br>
 src/mesa/drivers/dri/i965/brw_vec4.h              |  9 +++++++--<br>
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp    | 11 +----------<br>
 src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp | 12 ++++++------<br>
 3 files changed, 14 insertions(+), 18 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h<br>
index 19de4c6..50e4794 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_vec4.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h<br>
@@ -192,8 +192,13 @@ offset(dst_reg reg, unsigned delta)<br>
    return reg;<br>
 }<br>
<br>
-dst_reg<br>
-with_writemask(dst_reg const &r, int mask);<br>
+static inline dst_reg<br>
+writemask(dst_reg reg, unsigned mask)<br>
+{<br>
+   assert(reg.file != HW_REG && reg.file != IMM);<br>
+   reg.writemask &= mask;<br>
+   return reg;<br>
+}<br></blockquote><div><br></div><div>IIRC, hardware behaviour is undefined if the destination of an instruction has a writemask of 0.  Should we add an assertion here to verify that the new reg.writemask != 0?<br><br>With that addressed, this patch is:<br>
<br></div><div>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div></div></div></div>