From 75b24381674aa4a9e8859546360e5685827fff46 Mon Sep 17 00:00:00 2001 From: DanielSvoboda Date: Thu, 20 Feb 2025 16:36:46 -0300 Subject: [PATCH] Fix V_FFBL_B32 Added check in V_FFBL_B32 to return 0xFFFFFFFF when S0 is zero, similar to V_FFBH_U32. Otherwise, returns the position of the first low bit (bit 1) from LSB. Instruction V_FFBL_B32 Description Find first bit low. D.u = position of first 1 in S0 from LSB; D=0xFFFFFFFF if S0==0. --- src/shader_recompiler/frontend/translate/vector_alu.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/shader_recompiler/frontend/translate/vector_alu.cpp b/src/shader_recompiler/frontend/translate/vector_alu.cpp index 56e903052..fc5d4e952 100644 --- a/src/shader_recompiler/frontend/translate/vector_alu.cpp +++ b/src/shader_recompiler/frontend/translate/vector_alu.cpp @@ -837,7 +837,9 @@ void Translator::V_FFBH_U32(const GcnInst& inst) { void Translator::V_FFBL_B32(const GcnInst& inst) { const IR::U32 src0{GetSrc(inst.src[0])}; - SetDst(inst.dst[0], ir.FindILsb(src0)); + // Select 0xFFFFFFFF if src0 was 0 + const IR::U1 cond = ir.INotEqual(src0, ir.Imm32(0)); + SetDst(inst.dst[0], IR::U32{ir.Select(cond, ir.FindILsb(src0), ir.Imm32(~0U))}); } void Translator::V_FREXP_EXP_I32_F64(const GcnInst& inst) {