pan/midgard: avoid implicit cast-warning on Clang

BITFIELD_MASK() returns a 32-bit unsigned integer, and Clang complains
if we assign it to a 16-bit unsigned integer without a cast. Let's add
that cast.

While we're at it, add an assert() to make it clear to the compiler that
the condition in BITFIELD_MASK() can be optimized away.

Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Eric R. Smith <eric.smith@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36606>
This commit is contained in:
Erik Faye-Lund 2025-08-06 13:25:14 +02:00 committed by Marge Bot
parent e5fda871fd
commit 03b7054c30

View file

@ -1642,7 +1642,8 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
ins.dest_type = ins.src_types[1] = nir_type_uint | instr->def.bit_size;
ins.mask = BITFIELD_MASK(instr->def.num_components);
assert(instr->def.num_components <= 4);
ins.mask = (uint16_t)BITFIELD_MASK(instr->def.num_components);
emit_mir_instruction(ctx, &ins);
break;
}