@@ -14812,14 +14812,15 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
14812
14812
EVT ExtVT = cast<VTSDNode>(N1)->getVT();
14813
14813
unsigned VTBits = VT.getScalarSizeInBits();
14814
14814
unsigned ExtVTBits = ExtVT.getScalarSizeInBits();
14815
+ SDLoc DL(N);
14815
14816
14816
14817
// sext_vector_inreg(undef) = 0 because the top bit will all be the same.
14817
14818
if (N0.isUndef())
14818
- return DAG.getConstant(0, SDLoc(N) , VT);
14819
+ return DAG.getConstant(0, DL , VT);
14819
14820
14820
14821
// fold (sext_in_reg c1) -> c1
14821
14822
if (DAG.isConstantIntBuildVectorOrConstantInt(N0))
14822
- return DAG.getNode(ISD::SIGN_EXTEND_INREG, SDLoc(N) , VT, N0, N1);
14823
+ return DAG.getNode(ISD::SIGN_EXTEND_INREG, DL , VT, N0, N1);
14823
14824
14824
14825
// If the input is already sign extended, just drop the extension.
14825
14826
if (ExtVTBits >= DAG.ComputeMaxSignificantBits(N0))
@@ -14828,8 +14829,7 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
14828
14829
// fold (sext_in_reg (sext_in_reg x, VT2), VT1) -> (sext_in_reg x, minVT) pt2
14829
14830
if (N0.getOpcode() == ISD::SIGN_EXTEND_INREG &&
14830
14831
ExtVT.bitsLT(cast<VTSDNode>(N0.getOperand(1))->getVT()))
14831
- return DAG.getNode(ISD::SIGN_EXTEND_INREG, SDLoc(N), VT, N0.getOperand(0),
14832
- N1);
14832
+ return DAG.getNode(ISD::SIGN_EXTEND_INREG, DL, VT, N0.getOperand(0), N1);
14833
14833
14834
14834
// fold (sext_in_reg (sext x)) -> (sext x)
14835
14835
// fold (sext_in_reg (aext x)) -> (sext x)
@@ -14841,7 +14841,7 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
14841
14841
if ((N00Bits <= ExtVTBits ||
14842
14842
DAG.ComputeMaxSignificantBits(N00) <= ExtVTBits) &&
14843
14843
(!LegalOperations || TLI.isOperationLegal(ISD::SIGN_EXTEND, VT)))
14844
- return DAG.getNode(ISD::SIGN_EXTEND, SDLoc(N) , VT, N00);
14844
+ return DAG.getNode(ISD::SIGN_EXTEND, DL , VT, N00);
14845
14845
}
14846
14846
14847
14847
// fold (sext_in_reg (*_extend_vector_inreg x)) -> (sext_vector_inreg x)
@@ -14859,7 +14859,7 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
14859
14859
DAG.ComputeMaxSignificantBits(N00) <= ExtVTBits))) &&
14860
14860
(!LegalOperations ||
14861
14861
TLI.isOperationLegal(ISD::SIGN_EXTEND_VECTOR_INREG, VT)))
14862
- return DAG.getNode(ISD::SIGN_EXTEND_VECTOR_INREG, SDLoc(N) , VT, N00);
14862
+ return DAG.getNode(ISD::SIGN_EXTEND_VECTOR_INREG, DL , VT, N00);
14863
14863
}
14864
14864
14865
14865
// fold (sext_in_reg (zext x)) -> (sext x)
@@ -14868,12 +14868,12 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
14868
14868
SDValue N00 = N0.getOperand(0);
14869
14869
if (N00.getScalarValueSizeInBits() == ExtVTBits &&
14870
14870
(!LegalOperations || TLI.isOperationLegal(ISD::SIGN_EXTEND, VT)))
14871
- return DAG.getNode(ISD::SIGN_EXTEND, SDLoc(N) , VT, N00);
14871
+ return DAG.getNode(ISD::SIGN_EXTEND, DL , VT, N00);
14872
14872
}
14873
14873
14874
14874
// fold (sext_in_reg x) -> (zext_in_reg x) if the sign bit is known zero.
14875
14875
if (DAG.MaskedValueIsZero(N0, APInt::getOneBitSet(VTBits, ExtVTBits - 1)))
14876
- return DAG.getZeroExtendInReg(N0, SDLoc(N) , ExtVT);
14876
+ return DAG.getZeroExtendInReg(N0, DL , ExtVT);
14877
14877
14878
14878
// fold operands of sext_in_reg based on knowledge that the top bits are not
14879
14879
// demanded.
@@ -14895,7 +14895,7 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
14895
14895
// extended enough.
14896
14896
unsigned InSignBits = DAG.ComputeNumSignBits(N0.getOperand(0));
14897
14897
if (((VTBits - ExtVTBits) - ShAmt->getZExtValue()) < InSignBits)
14898
- return DAG.getNode(ISD::SRA, SDLoc(N) , VT, N0.getOperand(0),
14898
+ return DAG.getNode(ISD::SRA, DL , VT, N0.getOperand(0),
14899
14899
N0.getOperand(1));
14900
14900
}
14901
14901
}
@@ -14904,37 +14904,33 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
14904
14904
// If sextload is not supported by target, we can only do the combine when
14905
14905
// load has one use. Doing otherwise can block folding the extload with other
14906
14906
// extends that the target does support.
14907
- if (ISD::isEXTLoad(N0.getNode()) &&
14908
- ISD::isUNINDEXEDLoad(N0.getNode()) &&
14907
+ if (ISD::isEXTLoad(N0.getNode()) && ISD::isUNINDEXEDLoad(N0.getNode()) &&
14909
14908
ExtVT == cast<LoadSDNode>(N0)->getMemoryVT() &&
14910
14909
((!LegalOperations && cast<LoadSDNode>(N0)->isSimple() &&
14911
14910
N0.hasOneUse()) ||
14912
14911
TLI.isLoadExtLegal(ISD::SEXTLOAD, VT, ExtVT))) {
14913
- LoadSDNode *LN0 = cast<LoadSDNode>(N0);
14914
- SDValue ExtLoad = DAG.getExtLoad(ISD::SEXTLOAD, SDLoc(N), VT,
14915
- LN0->getChain(),
14916
- LN0->getBasePtr(), ExtVT,
14917
- LN0->getMemOperand());
14912
+ auto *LN0 = cast<LoadSDNode>(N0);
14913
+ SDValue ExtLoad =
14914
+ DAG.getExtLoad(ISD::SEXTLOAD, DL, VT, LN0->getChain(),
14915
+ LN0->getBasePtr(), ExtVT, LN0->getMemOperand());
14918
14916
CombineTo(N, ExtLoad);
14919
14917
CombineTo(N0.getNode(), ExtLoad, ExtLoad.getValue(1));
14920
14918
AddToWorklist(ExtLoad.getNode());
14921
- return SDValue(N, 0); // Return N so it doesn't get rechecked!
14919
+ return SDValue(N, 0); // Return N so it doesn't get rechecked!
14922
14920
}
14923
14921
14924
14922
// fold (sext_inreg (zextload x)) -> (sextload x) iff load has one use
14925
14923
if (ISD::isZEXTLoad(N0.getNode()) && ISD::isUNINDEXEDLoad(N0.getNode()) &&
14926
- N0.hasOneUse() &&
14927
- ExtVT == cast<LoadSDNode>(N0)->getMemoryVT() &&
14924
+ N0.hasOneUse() && ExtVT == cast<LoadSDNode>(N0)->getMemoryVT() &&
14928
14925
((!LegalOperations && cast<LoadSDNode>(N0)->isSimple()) &&
14929
14926
TLI.isLoadExtLegal(ISD::SEXTLOAD, VT, ExtVT))) {
14930
- LoadSDNode *LN0 = cast<LoadSDNode>(N0);
14931
- SDValue ExtLoad = DAG.getExtLoad(ISD::SEXTLOAD, SDLoc(N), VT,
14932
- LN0->getChain(),
14933
- LN0->getBasePtr(), ExtVT,
14934
- LN0->getMemOperand());
14927
+ auto *LN0 = cast<LoadSDNode>(N0);
14928
+ SDValue ExtLoad =
14929
+ DAG.getExtLoad(ISD::SEXTLOAD, DL, VT, LN0->getChain(),
14930
+ LN0->getBasePtr(), ExtVT, LN0->getMemOperand());
14935
14931
CombineTo(N, ExtLoad);
14936
14932
CombineTo(N0.getNode(), ExtLoad, ExtLoad.getValue(1));
14937
- return SDValue(N, 0); // Return N so it doesn't get rechecked!
14933
+ return SDValue(N, 0); // Return N so it doesn't get rechecked!
14938
14934
}
14939
14935
14940
14936
// fold (sext_inreg (masked_load x)) -> (sext_masked_load x)
@@ -14944,7 +14940,7 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
14944
14940
Ld->getExtensionType() != ISD::LoadExtType::NON_EXTLOAD &&
14945
14941
TLI.isLoadExtLegal(ISD::SEXTLOAD, VT, ExtVT)) {
14946
14942
SDValue ExtMaskedLoad = DAG.getMaskedLoad(
14947
- VT, SDLoc(N) , Ld->getChain(), Ld->getBasePtr(), Ld->getOffset(),
14943
+ VT, DL , Ld->getChain(), Ld->getBasePtr(), Ld->getOffset(),
14948
14944
Ld->getMask(), Ld->getPassThru(), ExtVT, Ld->getMemOperand(),
14949
14945
Ld->getAddressingMode(), ISD::SEXTLOAD, Ld->isExpandingLoad());
14950
14946
CombineTo(N, ExtMaskedLoad);
@@ -14955,15 +14951,14 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
14955
14951
14956
14952
// fold (sext_inreg (masked_gather x)) -> (sext_masked_gather x)
14957
14953
if (auto *GN0 = dyn_cast<MaskedGatherSDNode>(N0)) {
14958
- if (SDValue(GN0, 0).hasOneUse() &&
14959
- ExtVT == GN0->getMemoryVT() &&
14954
+ if (SDValue(GN0, 0).hasOneUse() && ExtVT == GN0->getMemoryVT() &&
14960
14955
TLI.isVectorLoadExtDesirable(SDValue(SDValue(GN0, 0)))) {
14961
14956
SDValue Ops[] = {GN0->getChain(), GN0->getPassThru(), GN0->getMask(),
14962
14957
GN0->getBasePtr(), GN0->getIndex(), GN0->getScale()};
14963
14958
14964
14959
SDValue ExtLoad = DAG.getMaskedGather(
14965
- DAG.getVTList(VT, MVT::Other), ExtVT, SDLoc(N) , Ops,
14966
- GN0->getMemOperand(), GN0-> getIndexType(), ISD::SEXTLOAD);
14960
+ DAG.getVTList(VT, MVT::Other), ExtVT, DL , Ops, GN0->getMemOperand() ,
14961
+ GN0->getIndexType(), ISD::SEXTLOAD);
14967
14962
14968
14963
CombineTo(N, ExtLoad);
14969
14964
CombineTo(N0.getNode(), ExtLoad, ExtLoad.getValue(1));
@@ -14976,7 +14971,7 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
14976
14971
if (ExtVTBits <= 16 && N0.getOpcode() == ISD::OR) {
14977
14972
if (SDValue BSwap = MatchBSwapHWordLow(N0.getNode(), N0.getOperand(0),
14978
14973
N0.getOperand(1), false))
14979
- return DAG.getNode(ISD::SIGN_EXTEND_INREG, SDLoc(N) , VT, BSwap, N1);
14974
+ return DAG.getNode(ISD::SIGN_EXTEND_INREG, DL , VT, BSwap, N1);
14980
14975
}
14981
14976
14982
14977
// Fold (iM_signext_inreg
@@ -14993,8 +14988,8 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
14993
14988
(!LegalOperations ||
14994
14989
TLI.isOperationLegal(ISD::SIGN_EXTEND, InnerExtVT))) {
14995
14990
SDValue SignExtExtendee =
14996
- DAG.getNode(ISD::SIGN_EXTEND, SDLoc(N) , InnerExtVT, Extendee);
14997
- return DAG.getNode(ISD::EXTRACT_SUBVECTOR, SDLoc(N) , VT, SignExtExtendee,
14991
+ DAG.getNode(ISD::SIGN_EXTEND, DL , InnerExtVT, Extendee);
14992
+ return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL , VT, SignExtExtendee,
14998
14993
N0.getOperand(1));
14999
14994
}
15000
14995
}
0 commit comments