<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 3, 2015 at 2:06 PM, Jason Ekstrand <span dir="ltr"><<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">SEL and MOV instructions, as long as they don't have source modifiers, are<br>
just copying bits around. This commit adds support to copy propagation to<br>
switch the type of a SEL or MOV instruction as needed so that it can<br>
propagate source modifiers. This is needed because NIR generates integer<br>
SEL and MOV instructions whenver it doesn't know what else to generate.<br>
<br>
shader-db results with NIR:<br>
total FS instructions in shared programs: 4360910 -> 4360186 (-0.02%)<br>
FS instructions in affected programs: 59094 -> 58370 (-1.23%)<br>
helped: 341<br>
HURT: 0<br>
GAINED: 2<br>
LOST: 0<br>
---<br>
.../drivers/dri/i965/brw_fs_copy_propagation.cpp | 33 +++++++++++++++++++---<br>
1 file changed, 29 insertions(+), 4 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 e8d092c..d321509 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>
@@ -275,6 +275,16 @@ is_logic_op(enum opcode opcode)<br>
opcode == BRW_OPCODE_NOT);<br>
}<br>
<br>
+static bool<br>
+can_change_source_types(fs_inst *inst)<br>
+{<br>
+ return !inst->src[0].abs && !inst->src[0].negate &&<br>
+ (inst->opcode == BRW_OPCODE_MOV ||<br>
+ (inst->opcode == BRW_OPCODE_SEL &&<br>
+ inst->conditional_mod == BRW_CONDITIONAL_NONE &&<br>
+ !inst->src[1].abs && !inst->src[1].negate));<br>
+}<br>
+<br>
bool<br>
fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry)<br>
{<br>
@@ -346,7 +356,9 @@ fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry)<br>
type_sz(inst->src[arg].type)) % type_sz(entry->src.type) != 0)<br>
return false;<br>
<br>
- if (has_source_modifiers && entry->dst.type != inst->src[arg].type)<br>
+ if (has_source_modifiers &&<br>
+ entry->dst.type != inst->src[arg].type &&<br>
+ !can_change_source_types(inst))<br>
return false;<br>
<br>
if (brw->gen >= 8 && (entry->src.negate || entry->src.abs) &&<br>
@@ -412,9 +424,22 @@ fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry)<br>
break;<br>
}<br>
<br>
- if (!inst->src[arg].abs) {<br>
- inst->src[arg].abs = entry->src.abs;<br>
- inst->src[arg].negate ^= entry->src.negate;<br>
+ if (has_source_modifiers) {<br>
+ if (entry->dst.type != inst->src[arg].type) {<br>
+ /* We are propagating source modifiers from a MOV with a different<br></blockquote><div>from a MOV or SEL ?</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+ * type. If we got here, then we can just change the source and<br>
+ * destination types of the instruction and keep going.<br>
+ */<br>
+ assert(can_change_source_types(inst));<br>
+ for (int i = 0; i < inst->sources; i++)<br>
+ inst->src[i].type = entry->dst.type;<br>
+ inst->dst.type = entry->dst.type;<br>
+ }<br>
+<br>
+ if (!inst->src[arg].abs) {<br>
+ inst->src[arg].abs = entry->src.abs;<br>
+ inst->src[arg].negate ^= entry->src.negate;<br>
+ }<br>
}<br>
<br>
return true;<br>
<span class=""><font color="#888888">--<br>
2.3.4<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 class="gmail_extra">Patches 1-2 are:</div><div class="gmail_extra">Reviewed-by: Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com">anuj.phogat@gmail.com</a>></div></div>