mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 17:58:26 +02:00
nir/uub: fix 8/16-bit overflow
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Backport-to: 25.1
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13552
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13553
Tested-by: @LingMan
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36372>
(cherry picked from commit a9a1da0264)
This commit is contained in:
parent
7994eaa8e6
commit
9a1b261529
2 changed files with 4 additions and 1 deletions
|
|
@ -1354,7 +1354,7 @@
|
|||
"description": "nir/uub: fix 8/16-bit overflow",
|
||||
"nominated": true,
|
||||
"nomination_type": 4,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null,
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -1840,11 +1840,13 @@ get_alu_uub(struct analysis_state *state, struct uub_query q, uint32_t *result,
|
|||
uint32_t src1 = MIN2(src[1], q.scalar.def->bit_size - 1u);
|
||||
if (util_last_bit64(src[0]) + src1 <= q.scalar.def->bit_size) /* check overflow */
|
||||
*result = src[0] << src1;
|
||||
*result = MIN2(*result, max);
|
||||
break;
|
||||
}
|
||||
case nir_op_imul:
|
||||
if (src[0] == 0 || (src[0] * src[1]) / src[0] == src[1]) /* check overflow */
|
||||
*result = src[0] * src[1];
|
||||
*result = MIN2(*result, max);
|
||||
break;
|
||||
case nir_op_ushr: {
|
||||
nir_scalar src1_scalar = nir_scalar_chase_alu_src(q.scalar, 1);
|
||||
|
|
@ -1867,6 +1869,7 @@ get_alu_uub(struct analysis_state *state, struct uub_query q, uint32_t *result,
|
|||
case nir_op_iadd:
|
||||
if (src[0] + src[1] >= src[0]) /* check overflow */
|
||||
*result = src[0] + src[1];
|
||||
*result = MIN2(*result, max);
|
||||
break;
|
||||
case nir_op_umod:
|
||||
*result = src[1] ? src[1] - 1 : 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue