[llvm] [SPIR-V] Fix crash on switch with odd-width condition type (PR #208026)
Dmitry Sidorov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 9 08:00:04 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;
----------------
MrSidims wrote:
> They are orthogonal. This fix does not depend on that. i1 is applicable in any case
Please add a test for it.
https://github.com/llvm/llvm-project/pull/208026
More information about the llvm-commits
mailing list