[llvm] 2804587 - [X86] combineConcatVectorOps - pull out repeated constant vector matching. NFC. (#172884)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 18 10:23:51 PST 2025
Author: Simon Pilgrim
Date: 2025-12-18T18:23:47Z
New Revision: 28045875777d1c5b1ca33317256517ff41d4ea69
URL: https://github.com/llvm/llvm-project/commit/28045875777d1c5b1ca33317256517ff41d4ea69
DIFF: https://github.com/llvm/llvm-project/commit/28045875777d1c5b1ca33317256517ff41d4ea69.diff
LOG: [X86] combineConcatVectorOps - pull out repeated constant vector matching. NFC. (#172884)
Hopefully improve this in the future to handle constant pool loads.
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 2711d2cd5f8ff..081038701b585 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -59103,7 +59103,11 @@ static SDValue combineConcatVectorOps(const SDLoc &DL, MVT VT,
}
return DAG.getNode(ISD::CONCAT_VECTORS, DL, VT, Subs);
};
- auto IsConcatFree = [](MVT VT, ArrayRef<SDValue> SubOps, unsigned Op) {
+ auto IsOpConstant = [](SDValue Op) -> bool {
+ return ISD::isBuildVectorOfConstantSDNodes(Op.getNode()) ||
+ ISD::isBuildVectorOfConstantFPSDNodes(Op.getNode());
+ };
+ auto IsConcatFree = [&](MVT VT, ArrayRef<SDValue> SubOps, unsigned Op) {
bool AllConstants = true;
bool AllSubs = true;
unsigned VecSize = VT.getSizeInBits();
@@ -59116,8 +59120,7 @@ static SDValue combineConcatVectorOps(const SDLoc &DL, MVT VT,
SDValue BC = peekThroughBitcasts(SubOps[I].getOperand(Op));
unsigned SubSize = BC.getValueSizeInBits();
unsigned EltSize = BC.getScalarValueSizeInBits();
- AllConstants &= ISD::isBuildVectorOfConstantSDNodes(BC.getNode()) ||
- ISD::isBuildVectorOfConstantFPSDNodes(BC.getNode());
+ AllConstants &= IsOpConstant(BC);
AllSubs &= BC.getOpcode() == ISD::EXTRACT_SUBVECTOR &&
BC.getOperand(0).getValueSizeInBits() == VecSize &&
(BC.getConstantOperandVal(1) * EltSize) == (I * SubSize);
@@ -59128,9 +59131,7 @@ static SDValue combineConcatVectorOps(const SDLoc &DL, MVT VT,
bool AllConstants = true;
SmallVector<SDValue> Subs;
for (SDValue SubOp : SubOps) {
- SDValue BC = peekThroughBitcasts(SubOp.getOperand(I));
- AllConstants &= ISD::isBuildVectorOfConstantSDNodes(BC.getNode()) ||
- ISD::isBuildVectorOfConstantFPSDNodes(BC.getNode());
+ AllConstants &= IsOpConstant(peekThroughBitcasts(SubOp.getOperand(I)));
Subs.push_back(SubOp.getOperand(I));
}
if (AllConstants)
More information about the llvm-commits
mailing list