[llvm] [SPIR-V] Fix crash on switch with odd-width condition type (PR #208026)
Juan Manuel Martinez CaamaƱo via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 9 01:53:35 PDT 2026
================
@@ -64,9 +64,14 @@ class SPIRVTargetLowering : public TargetLowering {
// the standard.
void finalizeLowering(MachineFunction &MF) const override;
+ // Return a width no larger than the condition so CodeGenPrepare never widens
+ // it. Odd-width integers are extended EVTs, so getSimpleVT would fail, so
+ // falling back to i1.
MVT getPreferredSwitchConditionType(LLVMContext &Context,
EVT ConditionVT) const override {
- return ConditionVT.getSimpleVT();
+ if (ConditionVT.isSimple())
+ return ConditionVT.getSimpleVT();
+ return MVT::i1;
----------------
jmmartinez wrote:
Just another question, what if we widened-it ? I'm wondering if we could just remove `getPreferredSwitchConditionType` and keep the base class's implementation; since the type is widened anyways.
https://github.com/llvm/llvm-project/pull/208026
More information about the llvm-commits
mailing list