<div dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 12, 2019 at 5:57 AM Iago Toral Quiroga <<a href="mailto:itoral@igalia.com">itoral@igalia.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">NIR already has these and correctly considers exact/inexact qualification,<br>
whereas the backend doesn't and can apply the optimizations where it<br>
shouldn't. This happened to be the case in a handful of Tomb Raider shaders,<br>
where NIR would skip the optimizations because of a precise qualification<br>
but the backend would then (incorrectly) apply them anyway.<br>
<br>
Besides this, considering that we are not emitting much math in the backend<br>
these days it is unlikely that these optimizations are useful in general. A<br>
shader-db run confirms that MAD and LRP optimizations, for example, were only<br>
being triggered in cases where NIR would skip them due to precise<br>
requirements, so in the near future we might want to remove more of these,<br>
but for now we just remove the ones that are not completely correct.<br>
<br>
Suggested-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>><br>
---<br>
src/intel/compiler/brw_fs.cpp | 39 +----------------------------------<br>
1 file changed, 1 insertion(+), 38 deletions(-)<br>
<br>
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp<br>
index 0f04e577de3..873a1dd8196 100644<br>
--- a/src/intel/compiler/brw_fs.cpp<br>
+++ b/src/intel/compiler/brw_fs.cpp<br>
@@ -2547,15 +2547,6 @@ fs_visitor::opt_algebraic()<br>
break;<br>
}<br>
<br>
- /* a * 0.0 = 0.0 */<br>
- if (inst->src[1].is_zero()) {<br>
- inst->opcode = BRW_OPCODE_MOV;<br>
- inst->src[0] = inst->src[1];<br>
- inst->src[1] = reg_undef;<br>
- progress = true;<br>
- break;<br>
- }<br>
-<br>
if (inst->src[0].file == IMM) {<br>
assert(inst->src[0].type == BRW_REGISTER_TYPE_F);<br>
inst->opcode = BRW_OPCODE_MOV;<br>
@@ -2569,14 +2560,6 @@ fs_visitor::opt_algebraic()<br>
if (inst->src[1].file != IMM)<br>
continue;<br>
<br>
- /* a + 0.0 = a */<br>
- if (inst->src[1].is_zero()) {<br>
- inst->opcode = BRW_OPCODE_MOV;<br>
- inst->src[1] = reg_undef;<br>
- progress = true;<br>
- break;<br>
- }<br>
-<br>
if (inst->src[0].file == IMM) {<br>
assert(inst->src[0].type == BRW_REGISTER_TYPE_F);<br>
inst->opcode = BRW_OPCODE_MOV;<br>
@@ -2595,16 +2578,6 @@ fs_visitor::opt_algebraic()<br>
break;<br>
}<br>
break;<br>
- case BRW_OPCODE_LRP:<br>
- if (inst->src[1].equals(inst->src[2])) {<br>
- inst->opcode = BRW_OPCODE_MOV;<br>
- inst->src[0] = inst->src[1];<br>
- inst->src[1] = reg_undef;<br>
- inst->src[2] = reg_undef;<br>
- progress = true;<br>
- break;<br>
- }<br>
- break;<br>
case BRW_OPCODE_CMP:<br>
if ((inst->conditional_mod == BRW_CONDITIONAL_Z ||<br>
inst->conditional_mod == BRW_CONDITIONAL_NZ) &&<br>
@@ -2682,17 +2655,7 @@ fs_visitor::opt_algebraic()<br>
}<br>
break;<br>
case BRW_OPCODE_MAD:<br>
- if (inst->src[1].is_zero() || inst->src[2].is_zero()) {<br>
- inst->opcode = BRW_OPCODE_MOV;<br>
- inst->src[1] = reg_undef;<br>
- inst->src[2] = reg_undef;<br>
- progress = true;<br>
- } else if (inst->src[0].is_zero()) {<br>
- inst->opcode = BRW_OPCODE_MUL;<br>
- inst->src[0] = inst->src[2];<br>
- inst->src[2] = reg_undef;<br>
- progress = true;<br>
- } else if (inst->src[1].is_one()) {<br>
+ if (inst->src[1].is_one()) {<br>
inst->opcode = BRW_OPCODE_ADD;<br>
inst->src[1] = inst->src[2];<br>
inst->src[2] = reg_undef;<br>
-- <br>
2.17.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">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></blockquote></div>