<div dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 30, 2018 at 7:18 AM, Iago Toral Quiroga <span dir="ltr"><<a href="mailto:itoral@igalia.com" target="_blank">itoral@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">These are not supported in hardware for 16-bit integers.<br>
<br>
We do the lowering pass after the optimization loop to ensure that we<br>
lower ALU operations injected by algebraic optimizations too.<br>
---<br>
src/intel/compiler/brw_nir.c | 21 +++++++++++++++++++++<br>
1 file changed, 21 insertions(+)<br>
<br>
diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c<br>
index 16b0d86814..fb5e08fb33 100644<br>
--- a/src/intel/compiler/brw_nir.c<br>
+++ b/src/intel/compiler/brw_nir.c<br>
@@ -590,6 +590,25 @@ brw_nir_optimize(nir_shader *nir, const struct brw_compiler *compiler,<br>
return nir;<br>
}<br>
<br>
+static unsigned<br>
+lower_bit_size_callback(const nir_alu_instr *alu, void *data)<br>
+{<br>
+ assert(alu->dest.dest.is_ssa);<br>
+ if (alu->dest.dest.ssa.bit_size != 16)<br>
+ return 0;<br>
+<br>
+ switch (alu->op) {<br>
+ case nir_op_idiv:<br>
+ case nir_op_imod:<br>
+ case nir_op_irem:<br>
+ case nir_op_udiv:<br>
+ case nir_op_umod:<br>
+ return 32;<br>
+ default:<br>
+ return 0;<br>
+ }<br>
+}<br>
+<br>
/* Does some simple lowering and runs the standard suite of optimizations<br>
*<br>
* This is intended to be called more-or-less directly after you get the<br>
@@ -643,6 +662,8 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir)<br>
<br>
nir = brw_nir_optimize(nir, compiler, is_scalar);<br>
<br>
+ nir_lower_bit_size(nir, lower_bit_size_callback, NULL);<br>
+<br>
if (is_scalar) {<br>
OPT(nir_lower_load_const_to_<wbr>scalar);<br>
}<br>
<span class="HOEnZb"><font color="#888888">-- <br>
2.14.1<br>
<br>
</font></span></blockquote></div><br></div>