@@ -17964,7 +17964,7 @@ SDValue DAGCombiner::visitFPOW(SDNode *N) {
17964
17964
return SDValue();
17965
17965
}
17966
17966
17967
- static SDValue foldFPToIntToFP(SDNode *N, SelectionDAG &DAG,
17967
+ static SDValue foldFPToIntToFP(SDNode *N, const SDLoc &DL, SelectionDAG &DAG,
17968
17968
const TargetLowering &TLI) {
17969
17969
// We only do this if the target has legal ftrunc. Otherwise, we'd likely be
17970
17970
// replacing casts with a libcall. We also must be allowed to ignore -0.0
@@ -17982,11 +17982,11 @@ static SDValue foldFPToIntToFP(SDNode *N, SelectionDAG &DAG,
17982
17982
SDValue N0 = N->getOperand(0);
17983
17983
if (N->getOpcode() == ISD::SINT_TO_FP && N0.getOpcode() == ISD::FP_TO_SINT &&
17984
17984
N0.getOperand(0).getValueType() == VT)
17985
- return DAG.getNode(ISD::FTRUNC, SDLoc(N) , VT, N0.getOperand(0));
17985
+ return DAG.getNode(ISD::FTRUNC, DL , VT, N0.getOperand(0));
17986
17986
17987
17987
if (N->getOpcode() == ISD::UINT_TO_FP && N0.getOpcode() == ISD::FP_TO_UINT &&
17988
17988
N0.getOperand(0).getValueType() == VT)
17989
- return DAG.getNode(ISD::FTRUNC, SDLoc(N) , VT, N0.getOperand(0));
17989
+ return DAG.getNode(ISD::FTRUNC, DL , VT, N0.getOperand(0));
17990
17990
17991
17991
return SDValue();
17992
17992
}
@@ -17995,49 +17995,45 @@ SDValue DAGCombiner::visitSINT_TO_FP(SDNode *N) {
17995
17995
SDValue N0 = N->getOperand(0);
17996
17996
EVT VT = N->getValueType(0);
17997
17997
EVT OpVT = N0.getValueType();
17998
+ SDLoc DL(N);
17998
17999
17999
18000
// [us]itofp(undef) = 0, because the result value is bounded.
18000
18001
if (N0.isUndef())
18001
- return DAG.getConstantFP(0.0, SDLoc(N) , VT);
18002
+ return DAG.getConstantFP(0.0, DL , VT);
18002
18003
18003
18004
// fold (sint_to_fp c1) -> c1fp
18004
18005
if (DAG.isConstantIntBuildVectorOrConstantInt(N0) &&
18005
18006
// ...but only if the target supports immediate floating-point values
18006
- (!LegalOperations ||
18007
- TLI.isOperationLegalOrCustom(ISD::ConstantFP, VT)))
18008
- return DAG.getNode(ISD::SINT_TO_FP, SDLoc(N), VT, N0);
18007
+ (!LegalOperations || TLI.isOperationLegalOrCustom(ISD::ConstantFP, VT)))
18008
+ return DAG.getNode(ISD::SINT_TO_FP, DL, VT, N0);
18009
18009
18010
18010
// If the input is a legal type, and SINT_TO_FP is not legal on this target,
18011
18011
// but UINT_TO_FP is legal on this target, try to convert.
18012
18012
if (!hasOperation(ISD::SINT_TO_FP, OpVT) &&
18013
18013
hasOperation(ISD::UINT_TO_FP, OpVT)) {
18014
18014
// If the sign bit is known to be zero, we can change this to UINT_TO_FP.
18015
18015
if (DAG.SignBitIsZero(N0))
18016
- return DAG.getNode(ISD::UINT_TO_FP, SDLoc(N) , VT, N0);
18016
+ return DAG.getNode(ISD::UINT_TO_FP, DL , VT, N0);
18017
18017
}
18018
18018
18019
18019
// The next optimizations are desirable only if SELECT_CC can be lowered.
18020
18020
// fold (sint_to_fp (setcc x, y, cc)) -> (select (setcc x, y, cc), -1.0, 0.0)
18021
18021
if (N0.getOpcode() == ISD::SETCC && N0.getValueType() == MVT::i1 &&
18022
18022
!VT.isVector() &&
18023
- (!LegalOperations || TLI.isOperationLegalOrCustom(ISD::ConstantFP, VT))) {
18024
- SDLoc DL(N);
18023
+ (!LegalOperations || TLI.isOperationLegalOrCustom(ISD::ConstantFP, VT)))
18025
18024
return DAG.getSelect(DL, VT, N0, DAG.getConstantFP(-1.0, DL, VT),
18026
18025
DAG.getConstantFP(0.0, DL, VT));
18027
- }
18028
18026
18029
18027
// fold (sint_to_fp (zext (setcc x, y, cc))) ->
18030
18028
// (select (setcc x, y, cc), 1.0, 0.0)
18031
18029
if (N0.getOpcode() == ISD::ZERO_EXTEND &&
18032
18030
N0.getOperand(0).getOpcode() == ISD::SETCC && !VT.isVector() &&
18033
- (!LegalOperations || TLI.isOperationLegalOrCustom(ISD::ConstantFP, VT))) {
18034
- SDLoc DL(N);
18031
+ (!LegalOperations || TLI.isOperationLegalOrCustom(ISD::ConstantFP, VT)))
18035
18032
return DAG.getSelect(DL, VT, N0.getOperand(0),
18036
18033
DAG.getConstantFP(1.0, DL, VT),
18037
18034
DAG.getConstantFP(0.0, DL, VT));
18038
- }
18039
18035
18040
- if (SDValue FTrunc = foldFPToIntToFP(N, DAG, TLI))
18036
+ if (SDValue FTrunc = foldFPToIntToFP(N, DL, DAG, TLI))
18041
18037
return FTrunc;
18042
18038
18043
18039
return SDValue();
@@ -18047,43 +18043,41 @@ SDValue DAGCombiner::visitUINT_TO_FP(SDNode *N) {
18047
18043
SDValue N0 = N->getOperand(0);
18048
18044
EVT VT = N->getValueType(0);
18049
18045
EVT OpVT = N0.getValueType();
18046
+ SDLoc DL(N);
18050
18047
18051
18048
// [us]itofp(undef) = 0, because the result value is bounded.
18052
18049
if (N0.isUndef())
18053
- return DAG.getConstantFP(0.0, SDLoc(N) , VT);
18050
+ return DAG.getConstantFP(0.0, DL , VT);
18054
18051
18055
18052
// fold (uint_to_fp c1) -> c1fp
18056
18053
if (DAG.isConstantIntBuildVectorOrConstantInt(N0) &&
18057
18054
// ...but only if the target supports immediate floating-point values
18058
- (!LegalOperations ||
18059
- TLI.isOperationLegalOrCustom(ISD::ConstantFP, VT)))
18060
- return DAG.getNode(ISD::UINT_TO_FP, SDLoc(N), VT, N0);
18055
+ (!LegalOperations || TLI.isOperationLegalOrCustom(ISD::ConstantFP, VT)))
18056
+ return DAG.getNode(ISD::UINT_TO_FP, DL, VT, N0);
18061
18057
18062
18058
// If the input is a legal type, and UINT_TO_FP is not legal on this target,
18063
18059
// but SINT_TO_FP is legal on this target, try to convert.
18064
18060
if (!hasOperation(ISD::UINT_TO_FP, OpVT) &&
18065
18061
hasOperation(ISD::SINT_TO_FP, OpVT)) {
18066
18062
// If the sign bit is known to be zero, we can change this to SINT_TO_FP.
18067
18063
if (DAG.SignBitIsZero(N0))
18068
- return DAG.getNode(ISD::SINT_TO_FP, SDLoc(N) , VT, N0);
18064
+ return DAG.getNode(ISD::SINT_TO_FP, DL , VT, N0);
18069
18065
}
18070
18066
18071
18067
// fold (uint_to_fp (setcc x, y, cc)) -> (select (setcc x, y, cc), 1.0, 0.0)
18072
18068
if (N0.getOpcode() == ISD::SETCC && !VT.isVector() &&
18073
- (!LegalOperations || TLI.isOperationLegalOrCustom(ISD::ConstantFP, VT))) {
18074
- SDLoc DL(N);
18069
+ (!LegalOperations || TLI.isOperationLegalOrCustom(ISD::ConstantFP, VT)))
18075
18070
return DAG.getSelect(DL, VT, N0, DAG.getConstantFP(1.0, DL, VT),
18076
18071
DAG.getConstantFP(0.0, DL, VT));
18077
- }
18078
18072
18079
- if (SDValue FTrunc = foldFPToIntToFP(N, DAG, TLI))
18073
+ if (SDValue FTrunc = foldFPToIntToFP(N, DL, DAG, TLI))
18080
18074
return FTrunc;
18081
18075
18082
18076
return SDValue();
18083
18077
}
18084
18078
18085
18079
// Fold (fp_to_{s/u}int ({s/u}int_to_fpx)) -> zext x, sext x, trunc x, or x
18086
- static SDValue FoldIntToFPToInt(SDNode *N, SelectionDAG &DAG) {
18080
+ static SDValue FoldIntToFPToInt(SDNode *N, const SDLoc &DL, SelectionDAG &DAG) {
18087
18081
SDValue N0 = N->getOperand(0);
18088
18082
EVT VT = N->getValueType(0);
18089
18083
@@ -18113,12 +18107,12 @@ static SDValue FoldIntToFPToInt(SDNode *N, SelectionDAG &DAG) {
18113
18107
// represented exactly in the float range.
18114
18108
if (APFloat::semanticsPrecision(Sem) >= ActualSize) {
18115
18109
if (VT.getScalarSizeInBits() > SrcVT.getScalarSizeInBits()) {
18116
- unsigned ExtOp = IsInputSigned && IsOutputSigned ? ISD::SIGN_EXTEND
18117
- : ISD::ZERO_EXTEND;
18118
- return DAG.getNode(ExtOp, SDLoc(N) , VT, Src);
18110
+ unsigned ExtOp =
18111
+ IsInputSigned && IsOutputSigned ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND;
18112
+ return DAG.getNode(ExtOp, DL , VT, Src);
18119
18113
}
18120
18114
if (VT.getScalarSizeInBits() < SrcVT.getScalarSizeInBits())
18121
- return DAG.getNode(ISD::TRUNCATE, SDLoc(N) , VT, Src);
18115
+ return DAG.getNode(ISD::TRUNCATE, DL , VT, Src);
18122
18116
return DAG.getBitcast(VT, Src);
18123
18117
}
18124
18118
return SDValue();
@@ -18127,31 +18121,33 @@ static SDValue FoldIntToFPToInt(SDNode *N, SelectionDAG &DAG) {
18127
18121
SDValue DAGCombiner::visitFP_TO_SINT(SDNode *N) {
18128
18122
SDValue N0 = N->getOperand(0);
18129
18123
EVT VT = N->getValueType(0);
18124
+ SDLoc DL(N);
18130
18125
18131
18126
// fold (fp_to_sint undef) -> undef
18132
18127
if (N0.isUndef())
18133
18128
return DAG.getUNDEF(VT);
18134
18129
18135
18130
// fold (fp_to_sint c1fp) -> c1
18136
18131
if (DAG.isConstantFPBuildVectorOrConstantFP(N0))
18137
- return DAG.getNode(ISD::FP_TO_SINT, SDLoc(N) , VT, N0);
18132
+ return DAG.getNode(ISD::FP_TO_SINT, DL , VT, N0);
18138
18133
18139
- return FoldIntToFPToInt(N, DAG);
18134
+ return FoldIntToFPToInt(N, DL, DAG);
18140
18135
}
18141
18136
18142
18137
SDValue DAGCombiner::visitFP_TO_UINT(SDNode *N) {
18143
18138
SDValue N0 = N->getOperand(0);
18144
18139
EVT VT = N->getValueType(0);
18140
+ SDLoc DL(N);
18145
18141
18146
18142
// fold (fp_to_uint undef) -> undef
18147
18143
if (N0.isUndef())
18148
18144
return DAG.getUNDEF(VT);
18149
18145
18150
18146
// fold (fp_to_uint c1fp) -> c1
18151
18147
if (DAG.isConstantFPBuildVectorOrConstantFP(N0))
18152
- return DAG.getNode(ISD::FP_TO_UINT, SDLoc(N) , VT, N0);
18148
+ return DAG.getNode(ISD::FP_TO_UINT, DL , VT, N0);
18153
18149
18154
- return FoldIntToFPToInt(N, DAG);
18150
+ return FoldIntToFPToInt(N, DL, DAG);
18155
18151
}
18156
18152
18157
18153
SDValue DAGCombiner::visitXROUND(SDNode *N) {
0 commit comments