[llvm] 3267de7 - [X86] combineAnd - pull out repeated getOperand() and SDLoc() calls. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 16 08:25:31 PST 2021
Author: Simon Pilgrim
Date: 2021-12-16T16:22:39Z
New Revision: 3267de7215e340562677434fd085e3e4c20af746
URL: https://github.com/llvm/llvm-project/commit/3267de7215e340562677434fd085e3e4c20af746
DIFF: https://github.com/llvm/llvm-project/commit/3267de7215e340562677434fd085e3e4c20af746.diff
LOG: [X86] combineAnd - pull out repeated getOperand() and SDLoc() calls. NFCI.
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 cdad73f87f9d..8e72ce75140f 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -46250,25 +46250,27 @@ static SDValue combineScalarAndWithMaskSetcc(SDNode *N, SelectionDAG &DAG,
static SDValue combineAnd(SDNode *N, SelectionDAG &DAG,
TargetLowering::DAGCombinerInfo &DCI,
const X86Subtarget &Subtarget) {
+ SDValue N0 = N->getOperand(0);
+ SDValue N1 = N->getOperand(1);
EVT VT = N->getValueType(0);
+ SDLoc dl(N);
+ const TargetLowering &TLI = DAG.getTargetLoweringInfo();
// If this is SSE1 only convert to FAND to avoid scalarization.
if (Subtarget.hasSSE1() && !Subtarget.hasSSE2() && VT == MVT::v4i32) {
- return DAG.getBitcast(
- MVT::v4i32, DAG.getNode(X86ISD::FAND, SDLoc(N), MVT::v4f32,
- DAG.getBitcast(MVT::v4f32, N->getOperand(0)),
- DAG.getBitcast(MVT::v4f32, N->getOperand(1))));
+ return DAG.getBitcast(MVT::v4i32,
+ DAG.getNode(X86ISD::FAND, dl, MVT::v4f32,
+ DAG.getBitcast(MVT::v4f32, N0),
+ DAG.getBitcast(MVT::v4f32, N1)));
}
// Use a 32-bit and+zext if upper bits known zero.
- if (VT == MVT::i64 && Subtarget.is64Bit() &&
- !isa<ConstantSDNode>(N->getOperand(1))) {
+ if (VT == MVT::i64 && Subtarget.is64Bit() && !isa<ConstantSDNode>(N1)) {
APInt HiMask = APInt::getHighBitsSet(64, 32);
- if (DAG.MaskedValueIsZero(N->getOperand(1), HiMask) ||
- DAG.MaskedValueIsZero(N->getOperand(0), HiMask)) {
- SDLoc dl(N);
- SDValue LHS = DAG.getNode(ISD::TRUNCATE, dl, MVT::i32, N->getOperand(0));
- SDValue RHS = DAG.getNode(ISD::TRUNCATE, dl, MVT::i32, N->getOperand(1));
+ if (DAG.MaskedValueIsZero(N1, HiMask) ||
+ DAG.MaskedValueIsZero(N0, HiMask)) {
+ SDValue LHS = DAG.getNode(ISD::TRUNCATE, dl, MVT::i32, N0);
+ SDValue RHS = DAG.getNode(ISD::TRUNCATE, dl, MVT::i32, N1);
return DAG.getNode(ISD::ZERO_EXTEND, dl, MVT::i64,
DAG.getNode(ISD::AND, dl, MVT::i32, LHS, RHS));
}
@@ -46281,8 +46283,6 @@ static SDValue combineAnd(SDNode *N, SelectionDAG &DAG,
SmallVector<APInt, 2> SrcPartials;
if (matchScalarReduction(SDValue(N, 0), ISD::AND, SrcOps, &SrcPartials) &&
SrcOps.size() == 1) {
- SDLoc dl(N);
- const TargetLowering &TLI = DAG.getTargetLoweringInfo();
unsigned NumElts = SrcOps[0].getValueType().getVectorNumElements();
EVT MaskVT = EVT::getIntegerVT(*DAG.getContext(), NumElts);
SDValue Mask = combineBitcastvxi1(DAG, MaskVT, SrcOps[0], dl, Subtarget);
@@ -46331,24 +46331,23 @@ static SDValue combineAnd(SDNode *N, SelectionDAG &DAG,
// Attempt to combine a scalar bitmask AND with an extracted shuffle.
if ((VT.getScalarSizeInBits() % 8) == 0 &&
- N->getOperand(0).getOpcode() == ISD::EXTRACT_VECTOR_ELT &&
- isa<ConstantSDNode>(N->getOperand(0).getOperand(1))) {
- SDValue BitMask = N->getOperand(1);
- SDValue SrcVec = N->getOperand(0).getOperand(0);
+ N0.getOpcode() == ISD::EXTRACT_VECTOR_ELT &&
+ isa<ConstantSDNode>(N0.getOperand(1))) {
+ SDValue BitMask = N1;
+ SDValue SrcVec = N0.getOperand(0);
EVT SrcVecVT = SrcVec.getValueType();
// Check that the constant bitmask masks whole bytes.
APInt UndefElts;
SmallVector<APInt, 64> EltBits;
- if (VT == SrcVecVT.getScalarType() &&
- N->getOperand(0)->isOnlyUserOf(SrcVec.getNode()) &&
+ if (VT == SrcVecVT.getScalarType() && N0->isOnlyUserOf(SrcVec.getNode()) &&
getTargetConstantBitsFromNode(BitMask, 8, UndefElts, EltBits) &&
llvm::all_of(EltBits, [](const APInt &M) {
return M.isZero() || M.isAllOnes();
})) {
unsigned NumElts = SrcVecVT.getVectorNumElements();
unsigned Scale = SrcVecVT.getScalarSizeInBits() / 8;
- unsigned Idx = N->getOperand(0).getConstantOperandVal(1);
+ unsigned Idx = N0.getConstantOperandVal(1);
// Create a root shuffle mask from the byte mask and the extracted index.
SmallVector<int, 16> ShuffleMask(NumElts * Scale, SM_SentinelUndef);
@@ -46364,8 +46363,8 @@ static SDValue combineAnd(SDNode *N, SelectionDAG &DAG,
X86::MaxShuffleCombineDepth,
/*HasVarMask*/ false, /*AllowVarCrossLaneMask*/ true,
/*AllowVarPerLaneMask*/ true, DAG, Subtarget))
- return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SDLoc(N), VT, Shuffle,
- N->getOperand(0).getOperand(1));
+ return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, VT, Shuffle,
+ N0.getOperand(1));
}
}
More information about the llvm-commits
mailing list