[llvm] [SPIR-V] Fix crash on switch with odd-width condition type (PR #208026)

Nick Sarnie via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 08:03:14 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;
----------------
sarnex wrote:

I agree with jmmartinez, if we can always use `i1` lets just use that, it makes the most sense IMO

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


More information about the llvm-commits mailing list