From 5a42df669b10ff15403422a6bf7b3da76f7adebe Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Thu, 26 Sep 2024 10:51:57 -0400 Subject: [PATCH] ir3: Ban conversions with mismatching sizes This prevents folding something like this: add.u hrA, hrB, hrC mov.u8u32 rD, hrA When I wrote this I assumed that because the conversion source and ALU destination were the same register that meant the types must have the same size, but that's not the case with u8 which is an 8-bit type in a 16-bit register, so this could've been broken with 8-bit types. Fixes: f58e1ef7ec5 ("tu: enable shaderInt8 support") Part-of: --- src/freedreno/ir3/ir3_cf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/freedreno/ir3/ir3_cf.c b/src/freedreno/ir3/ir3_cf.c index 8afa9920478..cd0f4bc4aed 100644 --- a/src/freedreno/ir3/ir3_cf.c +++ b/src/freedreno/ir3/ir3_cf.c @@ -52,9 +52,11 @@ is_safe_conv(struct ir3_instruction *instr, type_t src_type, opc_t *src_opc) return true; /* We can handle mismatches with integer types by converting the opcode - * but not when an integer is reinterpreted as a float or vice-versa. + * but not when an integer is reinterpreted as a float or vice-versa. We + * can't handle types with different sizes. */ - if (type_float(src_type) != type_float(instr->cat1.src_type)) + if (type_float(src_type) != type_float(instr->cat1.src_type) || + type_size(src_type) != type_size(instr->cat1.src_type)) return false; /* We have types with mismatched signedness. Mismatches on the signedness