[llvm] 0639fe1 - [X86] combineINSERT_SUBVECTOR - use peekThroughBitcastsAndExtracts helper to match target shuffles as well. NFC. (#209803)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 15 10:01:25 PDT 2026


Author: Simon Pilgrim
Date: 2026-07-15T18:01:20+01:00
New Revision: 0639fe182414f04d767175a195a8a26da5d48159

URL: https://github.com/llvm/llvm-project/commit/0639fe182414f04d767175a195a8a26da5d48159
DIFF: https://github.com/llvm/llvm-project/commit/0639fe182414f04d767175a195a8a26da5d48159.diff

LOG: [X86] combineINSERT_SUBVECTOR - use peekThroughBitcastsAndExtracts helper to match target shuffles as well. NFC. (#209803)

We were always checking if the result of peekThroughBitcastsAndExtracts
was a target shuffle - so let the helper do it for us.

Makes it easier for future handling of faux shuffles as well.

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86ISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index e02129525dd00..bb4b13e4feca4 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -61527,11 +61527,11 @@ static SDValue combineINSERT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
     }
   }
 
-  auto peekThroughBitcastsAndExtracts = [](SDValue V) {
+  auto isFoldableAsShuffle = [](SDValue V) {
     while (V.getOpcode() == ISD::BITCAST ||
            V.getOpcode() == ISD::EXTRACT_SUBVECTOR)
       V = V.getOperand(0);
-    return V;
+    return isTargetShuffle(V.getOpcode());
   };
 
   // Match concat_vector style patterns.
@@ -61553,10 +61553,7 @@ static SDValue combineINSERT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
                          SubVectorOps[0], DAG.getVectorIdxConstant(0, dl));
 
     // Attempt to recursively combine to a shuffle.
-    if (all_of(SubVectorOps, [&](SDValue SubOp) {
-          SubOp = peekThroughBitcastsAndExtracts(SubOp);
-          return isTargetShuffle(SubOp.getOpcode());
-        })) {
+    if (all_of(SubVectorOps, isFoldableAsShuffle)) {
       SDValue Op(N, 0);
       if (SDValue Res = combineX86ShufflesRecursively(Op, DAG, Subtarget))
         return Res;
@@ -61610,8 +61607,7 @@ static SDValue combineINSERT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
   }
 
   // Attempt to recursively combine to a shuffle.
-  if (isTargetShuffle(peekThroughBitcastsAndExtracts(Vec).getOpcode()) &&
-      isTargetShuffle(peekThroughBitcastsAndExtracts(SubVec).getOpcode())) {
+  if (isFoldableAsShuffle(Vec) && isFoldableAsShuffle(SubVec)) {
     SDValue Op(N, 0);
     if (SDValue Res = combineX86ShufflesRecursively(Op, DAG, Subtarget))
       return Res;


        


More information about the llvm-commits mailing list