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

Commit
61 days ago
[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.
Author
Parents
Loading