Skip to content

Conversation

@RKSimon
Copy link
Collaborator

@RKSimon RKSimon commented May 21, 2025

Use common helper and try to reduce the number of places we're generating load node directly.

…t fold to X86ISD::SUBV_BROADCAST_LOAD

Use common helper and try to reduce the number of places we're generating load node directly.
@llvmbot
Copy link
Member

llvmbot commented May 21, 2025

@llvm/pr-subscribers-backend-x86

Author: Simon Pilgrim (RKSimon)

Changes

Use common helper and try to reduce the number of places we're generating load node directly.


Full diff: https://github.com/llvm/llvm-project/pull/140919.diff

1 Files Affected:

  • (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+3-7)
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 6be34a3829b32..d6fcfb50f9e8f 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -59360,7 +59360,8 @@ static SDValue combineINSERT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
   }
 
   // If we're splatting the lower half subvector of a full vector load into the
-  // upper half, attempt to create a subvector broadcast.
+  // upper half, just splat the subvector directly, potentially creating a
+  // subvector broadcast.
   // TODO: Drop hasOneUse checks.
   if ((int)IdxVal == (VecNumElts / 2) &&
       Vec.getValueSizeInBits() == (2 * SubVec.getValueSizeInBits()) &&
@@ -59370,12 +59371,7 @@ static SDValue combineINSERT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
     if (VecLd && SubLd &&
         DAG.areNonVolatileConsecutiveLoads(
             SubLd, VecLd, SubVec.getValueSizeInBits() / 8, 0)) {
-      SDValue BcastLd = getBROADCAST_LOAD(X86ISD::SUBV_BROADCAST_LOAD, dl, OpVT,
-                                          SubVecVT, SubLd, 0, DAG);
-      SDValue NewSubVec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, SubVecVT,
-                                      BcastLd, DAG.getVectorIdxConstant(0, dl));
-      DCI.CombineTo(SubLd, NewSubVec, BcastLd.getValue(1));
-      return BcastLd;
+      return concatSubVectors(SubVec, SubVec, DAG, dl);
     }
   }
 

@RKSimon RKSimon merged commit f1d03de into llvm:main May 21, 2025
13 checks passed
@RKSimon RKSimon deleted the x86-concat-subvec-load branch May 21, 2025 20:37
RKSimon added a commit to RKSimon/llvm-project that referenced this pull request Jun 20, 2025
…ST_LOAD to prevent vector split infinite loop

This reverts llvm#140919 / f1d03de - which could result in another fold trying to split the concatenation apart again before it was folded to a SUBV_BROADCAST_LOAD
alexfh pushed a commit that referenced this pull request Jun 20, 2025
…ST_LOAD to prevent vector split infinite loop (#145077)

This reverts #140919 / f1d03de - which
could result in another fold trying to split the concatenation apart
again before it was folded to a SUBV_BROADCAST_LOAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants