[all-commits] [llvm/llvm-project] ca7b8d: [SPIRV] Fix compile abort on a switch case value s...

Diego Novillo via All-commits all-commits at lists.llvm.org
Fri Sep 18 05:57:47 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ca7b8dc0df161ae1b36ab97465351acf13e3b633
      https://github.com/llvm/llvm-project/commit/ca7b8dc0df161ae1b36ab97465351acf13e3b633
  Author: Diego Novillo <dnovillo at nvidia.com>
  Date:   2026-09-18 (Fri, 18 Sep 2026)

  Changed paths:
    M llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp
    A llvm/test/CodeGen/SPIRV/GlobalISel/prelegalizer-switch-case-constant.mir
    A llvm/test/CodeGen/SPIRV/GlobalISel/prelegalizer-switch-case-shared-constant.ll

  Log Message:
  -----------
  [SPIRV] Fix compile abort on a switch case value shared with a module constant (#223548)

This fixes a failure I found when compiling shaders whose switch case
value is also emitted as a module constant. LLVM currently aborts with

```
Assertion `isCImm() && "Wrong MachineOperand accessor"' failed.
```

in `MachineOperand::getCImm`. Three shaders in
[BigWheels](https://github.com/google/bigwheels) and
[Vulkan-Samples](https://github.com/KhronosGroup/Vulkan-Samples) run
into this.

A case operand is a `G_CONSTANT` until the module emits a SPIR-V
constant for the same value, at which point the case register is
replaced with that constant. Both forms have to decode to the case
value, and only `G_CONSTANT` did. The other holds the type in operand 1,
which was read as a `ConstantInt`.

This change decodes the value from either form, walking every 32-bit
literal word so any width survives.

I've added two tests:

- `prelegalizer-switch-case-shared-constant.ll` calls a function
returning `<1 x float>`, so the module emits the constant 1 as the
`OpTypeVectorIdEXT` component count. One of the two case values collides
with it and the other does not, so it covers both forms at 32 bits.
- `prelegalizer-switch-case-constant.mir` tests `i64` and `i128`, and a
null constant of each width.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list