<div dir="ltr"><div>Yeah, I think this is fine. We could expand the assert further to cover all possible casting cases but it's probably not worth it.</div><div><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div><br></div><div>--Jason<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Nov 20, 2018 at 4:14 AM Juan A. Suarez Romero <<a href="mailto:jasuarez@igalia.com">jasuarez@igalia.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, 2018-11-20 at 09:47 +0100, Iago Toral Quiroga wrote:<br>
> This reverts commit .<br>
> <br>
> For this to work the compiler must ensure that it never puts<br>
> the values that arrive to this helper into unsigned variables<br>
> at any point in its processing, since that would not apply sign<br>
> extension to the value and it would break the expectations here.<br>
> Unfortunately, we use uint64_t extensively to pass and copy<br>
> things around, so some times we get to this helper with values<br>
> that are not properly sign extended to 64-bit. Here is an example<br>
> for an 8-bit value that comes from a switch case:<br>
> <br>
> (gdb) p /x x<br>
> $1 = 0xffffffd6<br>
> <br>
> The value seems to have been copied to a 32-bit value at some point<br>
> getting proper sign extension, but then copied into a uint64_t<br>
> which wont' apply sign extension, breaking the expectations of<br>
> the assertion.<br>
<br>
<br>
This is fixing dEQP-VK.spirv_assembly.type.scalar.i16.switch_vert, which failing<br>
this assertion.<br>
<br>
Specifically, it is failing when dealing with this SPIR-V instruction:<br>
<br>
OpSwitch %input_val %default -3221 %case0 3210 %case1 19597 %case2<br>
<br>
And more specifically, when dealing with the -3221 value. Just to point out the<br>
values are int16.<br>
<br>
<br>
Additional, just to mention this wasn't caught by the Intel CI because the<br>
Vulkan CTS reference it uses to test master points to Vulkan CTS 1.1.0, which<br>
does not contain this test.<br>
<br>
What is the policty to update the testsuite references for master testing?<br>
Shouldn't use a more recent version of the test suite? The latest version is<br>
1.1.2.2, which makes the version used as reference a bit old.<br>
<br>
<br>
Reviewed-by: Juan A. Suarez <<a href="mailto:jasuarez@igalia.com" target="_blank">jasuarez@igalia.com</a>><br>
<br>
> ---<br>
> <br>
> FWIW, I tracked down the case where we were producing this and fixed<br>
> it, then the test that triggered this problem started to pass... but<br>
> others started to fail so I think it is best that we remove the assert<br>
> for now. If we want to keep this then I think we might need to do a<br>
> careful review of the compiler code and make sure we don't use any<br>
> unsigned types to copy things around to ensure that sign extension<br>
> happens consistently throughout.<br>
> <br>
> src/compiler/nir/nir_builder.h | 4 ----<br>
> 1 file changed, 4 deletions(-)<br>
> <br>
> diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h<br>
> index e37aba23dc..30fa1d7ec8 100644<br>
> --- a/src/compiler/nir/nir_builder.h<br>
> +++ b/src/compiler/nir/nir_builder.h<br>
> @@ -330,10 +330,6 @@ nir_imm_intN_t(nir_builder *build, uint64_t x, unsigned bit_size)<br>
> {<br>
> nir_const_value v;<br>
> <br>
> - assert(bit_size == 64 ||<br>
> - (int64_t)x >> bit_size == 0 ||<br>
> - (int64_t)x >> bit_size == -1);<br>
> -<br>
> memset(&v, 0, sizeof(v));<br>
> assert(bit_size <= 64);<br>
> v.i64[0] = x & (~0ull >> (64 - bit_size));<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><br>
</blockquote></div>