ir3/cf: don't swap signedness of (sat) instructions
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

Signed and unsigned saturation give different results.

Signed-off-by: Job Noorman <jnoorman@igalia.com>
Fixes: e894e83e47 ("ir3/cf: Rewrite pass")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37105>
This commit is contained in:
Job Noorman 2025-08-31 17:48:52 +02:00 committed by Marge Bot
parent e78bd88a06
commit 0c1ebc63ca

View file

@ -9,7 +9,8 @@
#include "ir3_shader.h"
static bool
is_safe_conv(struct ir3_instruction *instr, type_t src_type, opc_t *src_opc)
is_safe_conv(struct ir3_instruction *instr, type_t src_type, opc_t *src_opc,
struct ir3_instruction *src_instr)
{
if (instr->opc != OPC_MOV)
return false;
@ -66,6 +67,12 @@ is_safe_conv(struct ir3_instruction *instr, type_t src_type, opc_t *src_opc)
if (type_size(instr->cat1.dst_type) < type_size(instr->cat1.src_type))
return true;
/* Don't swap opcodes when the result is saturated as signed and unsigned
* saturation give different results.
*/
if (src_instr->flags & IR3_INSTR_SAT)
return false;
/* Try swapping the opcode: */
bool can_swap = true;
*src_opc = ir3_try_swap_signedness(*src_opc, &can_swap);
@ -79,7 +86,7 @@ all_uses_safe_conv(struct ir3_instruction *conv_src, type_t src_type)
bool first = true;
foreach_ssa_use (use, conv_src) {
opc_t new_opc = opc;
if (!is_safe_conv(use, src_type, &new_opc))
if (!is_safe_conv(use, src_type, &new_opc, conv_src))
return false;
/* Check if multiple uses have conflicting requirements on the opcode.
*/