[llvm] [X86] mayFoldIntoVector - recognise larger than legal logic ops may fold to vectors (PR #179503)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 3 09:12:23 PST 2026
https://github.com/RKSimon created https://github.com/llvm/llvm-project/pull/179503
Inspired by the hack to #174761 - move the custom operation handling inside mayFoldIntoVector where we can more accurately predict ops that can be moved to the vector unit
>From 52839613902d918cafb1efd997fd80e3329a7f2c Mon Sep 17 00:00:00 2001
From: Simon Pilgrim <llvm-dev at redking.me.uk>
Date: Tue, 3 Feb 2026 17:10:49 +0000
Subject: [PATCH] [X86] mayFoldIntoVector - recognise larger than legal logic
ops may fold to vectors
Inspired by the hack to #174761 - move the custom operation handling inside mayFoldIntoVector where we can more accurately predict ops that can be moved to the vector unit
---
llvm/lib/Target/X86/X86ISelLowering.cpp | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 1837c8bbedf0e..b2fac92676eaa 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -2901,6 +2901,11 @@ static bool mayFoldIntoVector(SDValue Op, const X86Subtarget &Subtarget,
return true;
if (isa<ConstantSDNode>(Op) || isa<ConstantFPSDNode>(Op))
return true;
+ EVT VT = Op.getValueType();
+ if (ISD::isBitwiseLogicOp(Op.getOpcode()) &&
+ (VT == MVT::i128 || VT == MVT::i256 || VT == MVT::i512))
+ return mayFoldIntoVector(Op.getOperand(0), Subtarget) &&
+ mayFoldIntoVector(Op.getOperand(1), Subtarget);
return X86::mayFoldLoad(Op, Subtarget, AssumeSingleUse,
/*IgnoreAlignment=*/true);
}
@@ -54561,10 +54566,7 @@ static SDValue combineStore(SDNode *N, SelectionDAG &DAG,
if (VT == MVT::i256 || VT == MVT::i512) {
MVT VecVT = MVT::getVectorVT(MVT::i64, VT.getSizeInBits() / 64);
if (TLI.isTypeLegal(VecVT) && ISD::isNormalStore(St) &&
- (mayFoldIntoVector(StoredVal, Subtarget) ||
- (DCI.isBeforeLegalize() &&
- TLI.getOperationAction(StoredVal.getOpcode(), VT) ==
- TargetLowering::LegalizeAction::Custom)))
+ mayFoldIntoVector(StoredVal, Subtarget))
return DAG.getStore(St->getChain(), dl, DAG.getBitcast(VecVT, StoredVal),
St->getBasePtr(), St->getPointerInfo(),
St->getBaseAlign(), St->getMemOperand()->getFlags());
More information about the llvm-commits
mailing list