<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Aug 29, 2017 at 11:54 PM, Alejandro Piñeiro <span dir="ltr"><<a href="mailto:apinheiro@igalia.com" target="_blank">apinheiro@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Although from SPIR-V point of view, rounding modes are attached to the<br>
operation/destination, on i965 it is a status, so we don't need to<br>
explicitly set the rounding mode if the one we want is already set.<br>
<br>
</span>v2: Use a single SHADER_OPCODE_RND_MODE opcode taking an immediate<br>
with the rounding mode (Curro)<br>
<br>
Signed-off-by: Jose Maria Casanova Crespo <<a href="mailto:jmcasanova@igalia.com">jmcasanova@igalia.com</a>><br>
Signed-off-by: Alejandro Piñeiro <<a href="mailto:apinheiro@igalia.com">apinheiro@igalia.com</a><br>
<br>
---<br>
src/intel/compiler/brw_fs.cpp | 41 ++++++++++++++++++++++++++++++<wbr>+++++++++++<br>
src/intel/compiler/brw_fs.h | 1 +<br>
2 files changed, 42 insertions(+)<br>
<br>
diff --git a/src/intel/compiler/brw_fs.<wbr>cpp b/src/intel/compiler/brw_fs.<wbr>cpp<br>
index 45236e3cab7..1b9ab0c0b88 100644<br>
--- a/src/intel/compiler/brw_fs.<wbr>cpp<br>
+++ b/src/intel/compiler/brw_fs.<wbr>cpp<br>
@@ -3071,6 +3071,46 @@ fs_visitor::remove_duplicate_<wbr>mrf_writes()<br>
<span class=""> return progress;<br>
}<br>
<br>
+/**<br>
+ * Rounding modes for conversion instructions are included for each<br>
+ * conversion, but right now it is a state. So once it is set,<br>
+ * we don't need to call it again for subsequent calls.<br>
+ *<br>
+ * This is useful for vector/matrices conversions, as setting the<br>
+ * mode once is enough for the full vector/matrix<br>
+ */<br>
+bool<br>
+fs_visitor::remove_extra_<wbr>rounding_modes()<br>
+{<br>
+ bool progress = false;<br>
+ /* By default, the rounding mode is rte, so we can consider it as the<br>
+ * starting rounding mode<br>
+ */<br>
</span>+ brw_rnd_mode prev_mode = BRW_RND_MODE_RTNE;<br></blockquote><div><br></div><div>This needs to be reset for every block. Otherwise, you may end up invalidly making assumptions about the rounding mode at the start of a loop or on two sides of an if. This probably means you should just use foreach_block and foreach_inst_safe separately.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="">+ brw_rnd_mode current_mode;<br></span></blockquote><div><br></div><div>I think I'd prefer this be declared right there in the loop where it's used. Maybe make it const and just call it "mode"?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
+<br>
+ foreach_block_and_inst_safe (block, fs_inst, inst, cfg) {<br>
</span>+ if (inst->opcode == SHADER_OPCODE_RND_MODE) {<br>
+ assert(inst->src[0].file == BRW_IMMEDIATE_VALUE);<br>
+<br>
+ current_mode = (brw_rnd_mode) inst->src[0].d;<br>
<span class="">+<br>
+ if (current_mode == prev_mode) {<br>
+ inst->remove(block);<br>
+ progress = true;<br>
+ } else {<br>
+ prev_mode = current_mode;<br>
+ }<br>
+ }<br>
+ }<br>
+<br>
+ if (progress)<br>
+ invalidate_live_intervals();<br>
+<br>
+ return progress;<br>
+}<br>
+<br>
+<br>
static void<br>
clear_deps_for_inst_src(fs_<wbr>inst *inst, bool *deps, int first_grf, int grf_len)<br>
{<br>
</span>@@ -5748,6 +5788,7 @@ fs_visitor::optimize()<br>
<div class="HOEnZb"><div class="h5"> int pass_num = 0;<br>
<br>
OPT(opt_drop_redundant_mov_to_<wbr>flags);<br>
+ OPT(remove_extra_rounding_<wbr>modes);<br>
<br>
do {<br>
progress = false;<br>
diff --git a/src/intel/compiler/brw_fs.h b/src/intel/compiler/brw_fs.h<br>
index f1ba193de7e..b9476e69edb 100644<br>
--- a/src/intel/compiler/brw_fs.h<br>
+++ b/src/intel/compiler/brw_fs.h<br>
@@ -150,6 +150,7 @@ public:<br>
bool eliminate_find_live_channel();<br>
bool dead_code_eliminate();<br>
bool remove_duplicate_mrf_writes();<br>
+ bool remove_extra_rounding_modes();<br>
<br>
bool opt_sampler_eot();<br>
bool virtual_grf_interferes(int a, int b);<br>
--<br>
2.11.0<br>
<br>
______________________________<wbr>_________________<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/<wbr>mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br></div></div>