[llvm] [X86][GISel] Fix crash on bitcasting i16 <-> half with gisel enabled. (PR #168456)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 19 03:31:56 PST 2025


================
@@ -312,6 +312,52 @@ bool X86InstructionSelector::selectCopy(MachineInstr &I,
       }
     }
 
+    const int RegBankSize = 16;
+
+    // Special case GPR16 -> XMM
+    if (SrcSize == RegBankSize && SrcRegBank.getID() == X86::GPRRegBankID &&
+        (DstRegBank.getID() == X86::VECRRegBankID)) {
+
+      const DebugLoc &DL = I.getDebugLoc();
+
+      // Zero extend GPR16 -> GPR32
+      Register ExtReg = MRI.createVirtualRegister(&X86::GR32RegClass);
+      BuildMI(*I.getParent(), I, DL, TII.get(X86::MOVZX32rr16), ExtReg)
----------------
RKSimon wrote:

we shouldn't need the zext - a copy/aext should work

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


More information about the llvm-commits mailing list