From 42c4d8353a65b2dd88bb810e131b60d66a6e8d8c Mon Sep 17 00:00:00 2001
From: xezrunner <8061077+xezrunner@users.noreply.github.com>
Date: Tue, 20 Aug 2024 22:48:28 +0200
Subject: [PATCH] Fix control.sopp.simm flipping sign in CFG label generation

This used to cause a fatal crash that would prevent Amplitude [CUSA02480] from booting beyond initialization.

A conditional true label would get an address starting with 0xffff...., which wasn't realistic with the given shader.

The multiplication by 4 causes the value to have its MSB set due to the smaller type.
---
 src/shader_recompiler/frontend/instruction.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shader_recompiler/frontend/instruction.cpp b/src/shader_recompiler/frontend/instruction.cpp
index d4847708..756d3b4e 100644
--- a/src/shader_recompiler/frontend/instruction.cpp
+++ b/src/shader_recompiler/frontend/instruction.cpp
@@ -7,7 +7,7 @@
 namespace Shader::Gcn {
 
 u32 GcnInst::BranchTarget(u32 pc) const {
-    const s16 simm = static_cast<s16>(control.sopp.simm * 4);
+    const s32 simm = static_cast<s32>(control.sopp.simm) * 4;
     const u32 target = pc + simm + 4;
     return target;
 }