[llvm] [AArch64][GlobalISel] Match G_DUP with undef elements (PR #195237)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri May 1 02:42:38 PDT 2026


================
@@ -855,14 +856,30 @@ bool matchBuildVectorToDup(MachineInstr &MI, MachineRegisterInfo &MRI) {
   if (isBuildVectorAllZeros(MI, MRI) || isBuildVectorAllOnes(MI, MRI))
     return false;
 
-  return getAArch64VectorSplat(MI, MRI).has_value();
+  // Find buildvector which always uses the same register or undef. Return true
+  // so long as at least 2 registers were found (not all-undef or only 1
+  // non-undef entry).
+  Register Reg = 0;
+  unsigned NumNonUndef = 0;
+  for (const MachineOperand &Op : drop_begin(MI.operands())) {
+    if (getOpcodeDef<GImplicitDef>(Op.getReg(), MRI))
----------------
arsenm wrote:

This reminds me we really need to resurrect the patch to add G_POISON 

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


More information about the llvm-commits mailing list