<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Nov 13, 2017 at 3:23 PM, Matt Turner <span dir="ltr"><<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The MOV instruction can extract bytes to words/double words, and<br>
words/double words to quadwords, but not byte to quadwords.<br>
<br>
For unsigned byte to quadword, we can read them as words and AND off the<br>
high byte and extract to quadword in one instruction. For signed bytes,<br>
we need to first sign extend to word and the sign extend that word to a<br>
quadword.<br>
<br>
Fixes the following test on CHV, BXT, and GLK:<br>
   KHR-GL46.shader_ballot_tests.<wbr>ShaderBallotBitmasks<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=103628" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/<wbr>show_bug.cgi?id=103628</a><br>
---<br>
 src/intel/compiler/brw_fs_nir.<wbr>cpp | 20 ++++++++++++++++++--<br>
 1 file changed, 18 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/intel/compiler/brw_fs_<wbr>nir.cpp b/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
index 38d0d357e8..e266837ece 100644<br>
--- a/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
+++ b/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
@@ -1395,10 +1395,26 @@ fs_visitor::nir_emit_alu(const fs_builder &bld, nir_alu_instr *instr)<br>
<br>
    case nir_op_extract_u8:<br>
    case nir_op_extract_i8: {<br>
-      const brw_reg_type type = brw_int_type(1, instr->op == nir_op_extract_i8);<br>
       nir_const_value *byte = nir_src_as_const_value(instr-><wbr>src[1].src);<br>
       assert(byte != NULL);<br>
-      bld.MOV(result, subscript(op[0], type, byte->u32[0]));<br>
+<br>
+      /* MOV does not support a 64-bit destination and a byte source */<br>
+      if (nir_dest_bit_size(instr-><wbr>dest.dest) == 64) {<br></blockquote><div><br></div><div>Do we also want to predicate this on "devinfo->is_cherrytrail || gen_device_info_is_gen9lp(devinfo)" as well as bit size?  Big-core can handle it just fine.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+         const brw_reg_type type = brw_int_type(2, instr->op == nir_op_extract_i8);<br>
+<br>
+         if (instr->op == nir_op_extract_i8) {<br>
+            /* If we need to sign extend, extract to a word first */<br>
+            fs_reg w_temp = bld.vgrf(BRW_REGISTER_TYPE_W);<br>
+            bld.MOV(w_temp, subscript(op[0], type, byte->u32[0]));<br>
+            bld.MOV(result, w_temp);<br>
+         } else {<br>
+            /* Otherwise use an AND with 0xff and a word type */<br>
+            bld.AND(result, subscript(op[0], type, byte->u32[0] / 2), brw_imm_uw(0xff));<br>
+         }<br>
+      } else {<br>
+         const brw_reg_type type = brw_int_type(1, instr->op == nir_op_extract_i8);<br>
+         bld.MOV(result, subscript(op[0], type, byte->u32[0]));<br>
+      }<br>
       break;<br>
    }<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.13.6<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>
</font></span></blockquote></div><br></div></div>