Commit 0b503d8d authored by Samuel Pitoiset's avatar Samuel Pitoiset Committed by Marge Bot
Browse files

nir: fix determining if an addition might overflow for phi sources

nir_addition_might_overflow() expects the parent instruction to be
an alu instr but it might be a phi instr. Fix it by assuming that
the addition might overflow.

This fixes compiler crashes with Horizon Zero Dawn.

No fossils-db changes.

Cc: mesa-stable
Signed-off-by: Samuel Pitoiset's avatarSamuel Pitoiset <>
Reviewed-by: Daniel Schürmann's avatarDaniel Schürmann <>
Part-of: <mesa/mesa!8268>
parent 129d390b
......@@ -1458,6 +1458,7 @@ nir_addition_might_overflow(nir_shader *shader, struct hash_table *range_ht,
nir_ssa_scalar ssa, unsigned const_val,
const nir_unsigned_upper_bound_config *config)
if (nir_ssa_scalar_is_alu(ssa)) {
nir_op alu_op = nir_ssa_scalar_alu_op(ssa);
/* iadd(imul(a, #b), #c) */
......@@ -1489,6 +1490,7 @@ nir_addition_might_overflow(nir_shader *shader, struct hash_table *range_ht,
if (mask == 0 || const_val < (1u << (ffs(mask) - 1)))
return false;
uint32_t ub = nir_unsigned_upper_bound(shader, range_ht, ssa, config);
return const_val + ub < const_val;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment