From 8948b74955fbac611af4887181b281cf5850a382 Mon Sep 17 00:00:00 2001 From: Mary Guillemard Date: Tue, 4 Mar 2025 10:12:42 +0100 Subject: [PATCH] pan/bi: Fix out of range access in bi_instr_replicates For replicates, we were checking equivalence between two sources on some instructions but some of them only had one source causing an out of bound access and check against unrelated data. Instead we now always return true for those instructions. Signed-off-by: Mary Guillemard Fixes: f7d44a46cd42 ("pan/bi: Optimize replication") Reviewed-by: Benjamin Lee Part-of: --- src/panfrost/compiler/bi_lower_swizzle.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/panfrost/compiler/bi_lower_swizzle.c b/src/panfrost/compiler/bi_lower_swizzle.c index 7e15764cde1..c68a915d31b 100644 --- a/src/panfrost/compiler/bi_lower_swizzle.c +++ b/src/panfrost/compiler/bi_lower_swizzle.c @@ -213,16 +213,18 @@ bi_instr_replicates(bi_instr *I, BITSET_WORD *replicates_16) * sources are identical. Check this case first. */ case BI_OPCODE_MKVEC_V2I16: + case BI_OPCODE_V2F32_TO_V2F16: + return bi_is_value_equiv(I->src[0], I->src[1]); + case BI_OPCODE_V2F16_TO_V2S16: case BI_OPCODE_V2F16_TO_V2U16: - case BI_OPCODE_V2F32_TO_V2F16: case BI_OPCODE_V2S16_TO_V2F16: case BI_OPCODE_V2S8_TO_V2F16: case BI_OPCODE_V2S8_TO_V2S16: case BI_OPCODE_V2U16_TO_V2F16: case BI_OPCODE_V2U8_TO_V2F16: case BI_OPCODE_V2U8_TO_V2U16: - return bi_is_value_equiv(I->src[0], I->src[1]); + return true; /* 16-bit transcendentals are defined to output zero in their * upper half, so they do not replicate