nir: fix nir_ishl_imm

Both GLSL & SPIRV have undefined values for shift > bitsize. But SM5
says :

   "This instruction performs a component-wise shift of each 32-bit
    value in src0 left by an unsigned integer bit count provided by
    the LSB 5 bits (0-31 range) in src1, inserting 0."

Better to not hard code the wrong behavior in NIR.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: e227bb9fd5 ("nir/builder: add ishl_imm helper")
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@colllabora.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21720>
(cherry picked from commit a278eeb719)
This commit is contained in:
Lionel Landwerlin 2023-03-05 23:12:36 +02:00 committed by Dylan Baker
parent 7fe567f98d
commit a0b65ff670
2 changed files with 2 additions and 3 deletions

View file

@ -3091,7 +3091,7 @@
"description": "nir: fix nir_ishl_imm",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "e227bb9fd58268788a79449ed247311744210279"
},

View file

@ -838,9 +838,8 @@ nir_ishl_imm(nir_builder *build, nir_ssa_def *x, uint32_t y)
{
if (y == 0) {
return x;
} else if (y >= x->bit_size) {
return nir_imm_intN_t(build, 0, x->bit_size);
} else {
assert (y < x->bit_size);
return nir_ishl(build, x, nir_imm_int(build, y));
}
}