Skip to content

Commit d592569

Browse files
committed
[DAG] visitAND - pull out repeated SDLoc(N). NFC.
1 parent ddcbab3 commit d592569

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6764,34 +6764,34 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
67646764
SDValue N0 = N->getOperand(0);
67656765
SDValue N1 = N->getOperand(1);
67666766
EVT VT = N1.getValueType();
6767+
SDLoc DL(N);
67676768

67686769
// x & x --> x
67696770
if (N0 == N1)
67706771
return N0;
67716772

67726773
// fold (and c1, c2) -> c1&c2
6773-
if (SDValue C = DAG.FoldConstantArithmetic(ISD::AND, SDLoc(N), VT, {N0, N1}))
6774+
if (SDValue C = DAG.FoldConstantArithmetic(ISD::AND, DL, VT, {N0, N1}))
67746775
return C;
67756776

67766777
// canonicalize constant to RHS
67776778
if (DAG.isConstantIntBuildVectorOrConstantInt(N0) &&
67786779
!DAG.isConstantIntBuildVectorOrConstantInt(N1))
6779-
return DAG.getNode(ISD::AND, SDLoc(N), VT, N1, N0);
6780+
return DAG.getNode(ISD::AND, DL, VT, N1, N0);
67806781

67816782
if (areBitwiseNotOfEachother(N0, N1))
6782-
return DAG.getConstant(APInt::getZero(VT.getScalarSizeInBits()), SDLoc(N),
6783-
VT);
6783+
return DAG.getConstant(APInt::getZero(VT.getScalarSizeInBits()), DL, VT);
67846784

67856785
// fold vector ops
67866786
if (VT.isVector()) {
6787-
if (SDValue FoldedVOp = SimplifyVBinOp(N, SDLoc(N)))
6787+
if (SDValue FoldedVOp = SimplifyVBinOp(N, DL))
67886788
return FoldedVOp;
67896789

67906790
// fold (and x, 0) -> 0, vector edition
67916791
if (ISD::isConstantSplatVectorAllZeros(N1.getNode()))
67926792
// do not return N1, because undef node may exist in N1
6793-
return DAG.getConstant(APInt::getZero(N1.getScalarValueSizeInBits()),
6794-
SDLoc(N), N1.getValueType());
6793+
return DAG.getConstant(APInt::getZero(N1.getScalarValueSizeInBits()), DL,
6794+
N1.getValueType());
67956795

67966796
// fold (and x, -1) -> x, vector edition
67976797
if (ISD::isConstantSplatVectorAllOnes(N1.getNode()))
@@ -6811,8 +6811,8 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
68116811
uint64_t ElementSize =
68126812
LoadVT.getVectorElementType().getScalarSizeInBits();
68136813
if (Splat->getAPIntValue().isMask(ElementSize)) {
6814-
auto NewLoad = DAG.getMaskedLoad(
6815-
ExtVT, SDLoc(N), MLoad->getChain(), MLoad->getBasePtr(),
6814+
SDValue NewLoad = DAG.getMaskedLoad(
6815+
ExtVT, DL, MLoad->getChain(), MLoad->getBasePtr(),
68166816
MLoad->getOffset(), MLoad->getMask(), MLoad->getPassThru(),
68176817
LoadVT, MLoad->getMemOperand(), MLoad->getAddressingMode(),
68186818
ISD::ZEXTLOAD, MLoad->isExpandingLoad());
@@ -6834,7 +6834,7 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
68346834
unsigned BitWidth = VT.getScalarSizeInBits();
68356835
ConstantSDNode *N1C = isConstOrConstSplat(N1);
68366836
if (N1C && DAG.MaskedValueIsZero(SDValue(N, 0), APInt::getAllOnes(BitWidth)))
6837-
return DAG.getConstant(0, SDLoc(N), VT);
6837+
return DAG.getConstant(0, DL, VT);
68386838

68396839
if (SDValue R = foldAndOrOfSETCC(N, DAG))
68406840
return R;
@@ -6843,12 +6843,12 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
68436843
return NewSel;
68446844

68456845
// reassociate and
6846-
if (SDValue RAND = reassociateOps(ISD::AND, SDLoc(N), N0, N1, N->getFlags()))
6846+
if (SDValue RAND = reassociateOps(ISD::AND, DL, N0, N1, N->getFlags()))
68476847
return RAND;
68486848

68496849
// Fold and(vecreduce(x), vecreduce(y)) -> vecreduce(and(x, y))
6850-
if (SDValue SD = reassociateReduction(ISD::VECREDUCE_AND, ISD::AND, SDLoc(N),
6851-
VT, N0, N1))
6850+
if (SDValue SD =
6851+
reassociateReduction(ISD::VECREDUCE_AND, ISD::AND, DL, VT, N0, N1))
68526852
return SD;
68536853

68546854
// fold (and (or x, C), D) -> D if (C & D) == D
@@ -6868,18 +6868,16 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
68686868

68696869
// fold (and (any_ext V), c) -> (zero_ext V) if 'and' only clears top bits.
68706870
if (DAG.MaskedValueIsZero(N0Op0, Mask))
6871-
return DAG.getNode(ISD::ZERO_EXTEND, SDLoc(N), VT, N0Op0);
6871+
return DAG.getNode(ISD::ZERO_EXTEND, DL, VT, N0Op0);
68726872

68736873
// fold (and (any_ext V), c) -> (zero_ext (and (trunc V), c)) if profitable.
68746874
if (N1C->getAPIntValue().countLeadingZeros() >= (BitWidth - SrcBitWidth) &&
68756875
TLI.isTruncateFree(VT, SrcVT) && TLI.isZExtFree(SrcVT, VT) &&
68766876
TLI.isTypeDesirableForOp(ISD::AND, SrcVT) &&
6877-
TLI.isNarrowingProfitable(VT, SrcVT)) {
6878-
SDLoc DL(N);
6877+
TLI.isNarrowingProfitable(VT, SrcVT))
68796878
return DAG.getNode(ISD::ZERO_EXTEND, DL, VT,
68806879
DAG.getNode(ISD::AND, DL, SrcVT, N0Op0,
68816880
DAG.getZExtOrTrunc(N1, DL, SrcVT)));
6882-
}
68836881
}
68846882

68856883
// fold (and (ext (and V, c1)), c2) -> (and (ext V), (and c1, (ext c2)))
@@ -6891,7 +6889,6 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
68916889
DAG.isConstantIntBuildVectorOrConstantInt(N1) &&
68926890
DAG.isConstantIntBuildVectorOrConstantInt(N0Op0.getOperand(1)) &&
68936891
N0->hasOneUse() && N0Op0->hasOneUse()) {
6894-
SDLoc DL(N);
68956892
SDValue NewMask =
68966893
DAG.getNode(ISD::AND, DL, VT, N1,
68976894
DAG.getNode(ExtOpc, DL, VT, N0Op0.getOperand(1)));
@@ -6912,8 +6909,8 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
69126909
N0.getOperand(0).getOpcode() == ISD::LOAD &&
69136910
N0.getOperand(0).getResNo() == 0) ||
69146911
(N0.getOpcode() == ISD::LOAD && N0.getResNo() == 0)) {
6915-
LoadSDNode *Load = cast<LoadSDNode>( (N0.getOpcode() == ISD::LOAD) ?
6916-
N0 : N0.getOperand(0) );
6912+
auto *Load =
6913+
cast<LoadSDNode>((N0.getOpcode() == ISD::LOAD) ? N0 : N0.getOperand(0));
69176914

69186915
// Get the constant (if applicable) the zero'th operand is being ANDed with.
69196916
// This can be a pure constant or a vector splat, in which case we treat the
@@ -7023,9 +7020,9 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
70237020
// (and (extract_subvector (zext|anyext|sext v) _) iN_mask)
70247021
// => (extract_subvector (iN_zeroext v))
70257022
SDValue ZeroExtExtendee =
7026-
DAG.getNode(ISD::ZERO_EXTEND, SDLoc(N), ExtVT, Extendee);
7023+
DAG.getNode(ISD::ZERO_EXTEND, DL, ExtVT, Extendee);
70277024

7028-
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, SDLoc(N), VT, ZeroExtExtendee,
7025+
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, ZeroExtExtendee,
70297026
N0.getOperand(1));
70307027
}
70317028
}
@@ -7042,8 +7039,8 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
70427039
GN0->getBasePtr(), GN0->getIndex(), GN0->getScale()};
70437040

70447041
SDValue ZExtLoad = DAG.getMaskedGather(
7045-
DAG.getVTList(VT, MVT::Other), MemVT, SDLoc(N), Ops,
7046-
GN0->getMemOperand(), GN0->getIndexType(), ISD::ZEXTLOAD);
7042+
DAG.getVTList(VT, MVT::Other), MemVT, DL, Ops, GN0->getMemOperand(),
7043+
GN0->getIndexType(), ISD::ZEXTLOAD);
70477044

70487045
CombineTo(N, ZExtLoad);
70497046
AddToWorklist(ZExtLoad.getNode());
@@ -7095,7 +7092,7 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
70957092
return SubRHS;
70967093
if (SubRHS.getOpcode() == ISD::SIGN_EXTEND &&
70977094
SubRHS.getOperand(0).getScalarValueSizeInBits() == 1)
7098-
return DAG.getNode(ISD::ZERO_EXTEND, SDLoc(N), VT, SubRHS.getOperand(0));
7095+
return DAG.getNode(ISD::ZERO_EXTEND, DL, VT, SubRHS.getOperand(0));
70997096
}
71007097
}
71017098

@@ -7109,7 +7106,7 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
71097106
if (ISD::isUNINDEXEDLoad(N0.getNode()) &&
71107107
(ISD::isEXTLoad(N0.getNode()) ||
71117108
(ISD::isSEXTLoad(N0.getNode()) && N0.hasOneUse()))) {
7112-
LoadSDNode *LN0 = cast<LoadSDNode>(N0);
7109+
auto *LN0 = cast<LoadSDNode>(N0);
71137110
EVT MemVT = LN0->getMemoryVT();
71147111
// If we zero all the possible extended bits, then we can turn this into
71157112
// a zextload if we are running before legalize or the operation is legal.
@@ -7164,7 +7161,7 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
71647161

71657162
// Replace (and (sign_extend ...) #bitmask) with (zero_extend ...).
71667163
if (IsAndZeroExtMask(N0, N1))
7167-
return DAG.getNode(ISD::ZERO_EXTEND, SDLoc(N), VT, N0.getOperand(0));
7164+
return DAG.getNode(ISD::ZERO_EXTEND, DL, VT, N0.getOperand(0));
71687165

71697166
if (hasOperation(ISD::USUBSAT, VT))
71707167
if (SDValue V = foldAndToUsubsat(N, DAG))

0 commit comments

Comments
 (0)