[llvm] [SPIRV] Fix compile abort on a switch case value shared with a module constant (PR #223548)

Diego Novillo via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 16 11:19:31 PDT 2026


================
@@ -1118,6 +1118,37 @@ static void insertSpirvDecorations(MachineFunction &MF, SPIRVGlobalRegistry *GR,
     invalidateAndEraseMI(GR, MI);
 }
 
+// Returns the value of the switch case operand defined by Def. For G_CONSTANTs,
+// this is in operand 1. For SPIR-V constants, this is in the literal operands
+// after the type.
+static const ConstantInt *getSwitchCaseValue(const MachineInstr *Def,
+                                             const MachineRegisterInfo &MRI) {
+  if (Def->getOpcode() == TargetOpcode::G_CONSTANT)
----------------
dnovillo wrote:

Done, thanks. I kept the loop over the literal words of a selected `OpConstantI`. I could not find a matcher for that.

https://github.com/llvm/llvm-project/pull/223548


More information about the llvm-commits mailing list