Skip to content

intel/compiler: Properly handle shift count for 8-bit sources

Ian Romanick requested to merge idr/mesa:fix-8-bit-shift into staging/21.0

This fixes the Crucible func.shader.shift.int8_t test on Gen8 and Gen9. See crucible!76 (merged).

No changes in fossil-db because there are no shaders in fossil-db that use shaderInt8. :(

A couple alternatives were considered.

  1. Lower 8-bit integers to 16-bit on all platforms. I looked at the output of a few shaders from the Vulkan CTS, and it was a mess. There were so many extra type converting MOVs. I think all of that could be cleaned up, but it would be more work. It would also not be great for cherry-picking to a stable branch.

    This is the approach that will be taken Mesa 21.1. See also !8730 (closed).

  2. Disable the optimization that prunes the & 7. This would be more optimal in shaders that don't have the explicit mask, but it's not very future proof. It would potentially require auditing future optimizations to make sure they don't run afoul of this problem.

In the end, the easiest solution seems to be adding the extra mask to implement the specified semantics of the NIR shift instructions... especially since the only shaders we have that use shaderInt8 are from the CTS.

Fixes: 26fc5e1f ("nir/algebraic: expand existing 32-bit patterns to all bit sizes using loops")

@dbaker: I've never submitted an MR directly against a stable branch. Please let me know if I didn't do this correctly.

Merge request reports