[llvm] [X86] matchUnaryShuffle - only prefer VZEXT_MOVL to VPMOVZX if it will fold away (PR #207031)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 2 10:55:59 PDT 2026


================
@@ -40200,19 +40200,16 @@ static bool matchUnaryShuffle(MVT MaskVT, ArrayRef<int> Mask,
   unsigned NumMaskElts = Mask.size();
   unsigned MaskEltSize = MaskVT.getScalarSizeInBits();
 
-  // Match against a VZEXT_MOVL vXi32 and vXi16 zero-extending instruction.
-  if (Mask[0] == 0 &&
-      (MaskEltSize == 32 || (MaskEltSize == 16 && Subtarget.hasFP16()))) {
-    if ((isUndefOrZero(Mask[1]) && isUndefInRange(Mask, 2, NumMaskElts - 2)) ||
-        (V1.getOpcode() == ISD::SCALAR_TO_VECTOR &&
-         isUndefOrZeroInRange(Mask, 1, NumMaskElts - 1))) {
-      Shuffle = X86ISD::VZEXT_MOVL;
-      if (MaskEltSize == 16)
-        SrcVT = DstVT = MaskVT.changeVectorElementType(MVT::f16);
-      else
-        SrcVT = DstVT = !Subtarget.hasSSE2() ? MVT::v4f32 : MaskVT;
-      return true;
-    }
+  // Match against a foldable vXi32/vXi16 VZEXT_MOVL zero-extending instruction.
+  if (Mask[0] == 0 && isUndefOrZeroInRange(Mask, 1, NumMaskElts - 1) &&
----------------
RKSimon wrote:

Sure - but I'd like to keep the shuffle matching all together so I'll move the Mask[0] check as well.

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


More information about the llvm-commits mailing list