From a0b65ff6701662d3c9ad48c449e69e79c6d2533c Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Sun, 5 Mar 2023 23:12:36 +0200 Subject: [PATCH] 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 Fixes: e227bb9fd5 ("nir/builder: add ishl_imm helper") Reviewed-by: Alyssa Rosenzweig Reviewed-by: Faith Ekstrand Part-of: (cherry picked from commit a278eeb71974a89b6dd7c0fa3dbfe97183aeb657) --- .pick_status.json | 2 +- src/compiler/nir/nir_builder.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index cc6a58d9158..d195c8c6255 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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" }, diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index d954cb98803..359684d10d6 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -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)); } }