Skip to content

Commit 51bad73

Browse files
committed
[SelectionDAG] Replace EVTToAPFloatSemantics with MVT/EVT::getFltSemantics. (#103001)
1 parent ae466a6 commit 51bad73

File tree

11 files changed

+62
-78
lines changed

11 files changed

+62
-78
lines changed

llvm/include/llvm/CodeGen/SelectionDAG.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,12 +1819,6 @@ class SelectionDAG {
18191819
AllNodes.insert(Position, AllNodes.remove(N));
18201820
}
18211821

1822-
/// Returns an APFloat semantics tag appropriate for the given type. If VT is
1823-
/// a vector type, the element semantics are returned.
1824-
static const fltSemantics &EVTToAPFloatSemantics(EVT VT) {
1825-
return VT.getFltSemantics();
1826-
}
1827-
18281822
/// Add a dbg_value SDNode. If SD is non-null that means the
18291823
/// value is produced by SD.
18301824
void AddDbgValue(SDDbgValue *DB, bool isParameter);
@@ -2365,7 +2359,7 @@ class SelectionDAG {
23652359
/// Return the current function's default denormal handling kind for the given
23662360
/// floating point type.
23672361
DenormalMode getDenormalMode(EVT VT) const {
2368-
return MF->getDenormalMode(EVTToAPFloatSemantics(VT));
2362+
return MF->getDenormalMode(VT.getFltSemantics());
23692363
}
23702364

23712365
bool shouldOptForSize() const;

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17804,11 +17804,11 @@ static SDValue FoldIntToFPToInt(SDNode *N, SelectionDAG &DAG) {
1780417804
unsigned InputSize = (int)SrcVT.getScalarSizeInBits() - IsInputSigned;
1780517805
unsigned OutputSize = (int)VT.getScalarSizeInBits();
1780617806
unsigned ActualSize = std::min(InputSize, OutputSize);
17807-
const fltSemantics &sem = DAG.EVTToAPFloatSemantics(N0.getValueType());
17807+
const fltSemantics &Sem = N0.getValueType().getFltSemantics();
1780817808

1780917809
// We can only fold away the float conversion if the input range can be
1781017810
// represented exactly in the float range.
17811-
if (APFloat::semanticsPrecision(sem) >= ActualSize) {
17811+
if (APFloat::semanticsPrecision(Sem) >= ActualSize) {
1781217812
if (VT.getScalarSizeInBits() > SrcVT.getScalarSizeInBits()) {
1781317813
unsigned ExtOp = IsInputSigned && IsOutputSigned ? ISD::SIGN_EXTEND
1781417814
: ISD::ZERO_EXTEND;
@@ -22599,7 +22599,7 @@ SDValue DAGCombiner::visitEXTRACT_VECTOR_ELT(SDNode *N) {
2259922599
KnownBits KnownElt = DAG.computeKnownBits(VecOp, EltMask);
2260022600
if (KnownElt.isConstant()) {
2260122601
APFloat CstFP =
22602-
APFloat(DAG.EVTToAPFloatSemantics(ScalarVT), KnownElt.getConstant());
22602+
APFloat(ScalarVT.getFltSemantics(), KnownElt.getConstant());
2260322603
if (TLI.isFPImmLegal(CstFP, ScalarVT))
2260422604
return DAG.getConstantFP(CstFP, DL, ScalarVT);
2260522605
}

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,7 +2435,7 @@ SDValue SelectionDAGLegalize::expandLdexp(SDNode *Node) const {
24352435

24362436
EVT SetCCVT =
24372437
TLI.getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), ExpVT);
2438-
const fltSemantics &FltSem = SelectionDAG::EVTToAPFloatSemantics(VT);
2438+
const fltSemantics &FltSem = VT.getFltSemantics();
24392439

24402440
const APFloat::ExponentType MaxExpVal = APFloat::semanticsMaxExponent(FltSem);
24412441
const APFloat::ExponentType MinExpVal = APFloat::semanticsMinExponent(FltSem);
@@ -2535,7 +2535,7 @@ SDValue SelectionDAGLegalize::expandFrexp(SDNode *Node) const {
25352535
if (AsIntVT == EVT()) // TODO: How to handle f80?
25362536
return SDValue();
25372537

2538-
const fltSemantics &FltSem = SelectionDAG::EVTToAPFloatSemantics(VT);
2538+
const fltSemantics &FltSem = VT.getFltSemantics();
25392539
const APFloat::ExponentType MinExpVal = APFloat::semanticsMinExponent(FltSem);
25402540
const unsigned Precision = APFloat::semanticsPrecision(FltSem);
25412541
const unsigned BitSize = VT.getScalarSizeInBits();
@@ -2797,7 +2797,7 @@ SDValue SelectionDAGLegalize::ExpandLegalINT_TO_FP(SDNode *Node,
27972797
// The following optimization is valid only if every value in SrcVT (when
27982798
// treated as signed) is representable in DestVT. Check that the mantissa
27992799
// size of DestVT is >= than the number of bits in SrcVT -1.
2800-
assert(APFloat::semanticsPrecision(DAG.EVTToAPFloatSemantics(DestVT)) >=
2800+
assert(APFloat::semanticsPrecision(DestVT.getFltSemantics()) >=
28012801
SrcVT.getSizeInBits() - 1 &&
28022802
"Cannot perform lossless SINT_TO_FP!");
28032803

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,12 +1493,9 @@ void DAGTypeLegalizer::ExpandFloatRes_ConstantFP(SDNode *N, SDValue &Lo,
14931493
"Do not know how to expand this float constant!");
14941494
APInt C = cast<ConstantFPSDNode>(N)->getValueAPF().bitcastToAPInt();
14951495
SDLoc dl(N);
1496-
Lo = DAG.getConstantFP(APFloat(DAG.EVTToAPFloatSemantics(NVT),
1497-
APInt(64, C.getRawData()[1])),
1498-
dl, NVT);
1499-
Hi = DAG.getConstantFP(APFloat(DAG.EVTToAPFloatSemantics(NVT),
1500-
APInt(64, C.getRawData()[0])),
1501-
dl, NVT);
1496+
const fltSemantics &Sem = NVT.getFltSemantics();
1497+
Lo = DAG.getConstantFP(APFloat(Sem, APInt(64, C.getRawData()[1])), dl, NVT);
1498+
Hi = DAG.getConstantFP(APFloat(Sem, APInt(64, C.getRawData()[0])), dl, NVT);
15021499
}
15031500

15041501
void DAGTypeLegalizer::ExpandFloatRes_Unary(SDNode *N, RTLIB::Libcall LC,
@@ -1777,8 +1774,8 @@ void DAGTypeLegalizer::ExpandFloatRes_FP_EXTEND(SDNode *N, SDValue &Lo,
17771774
Hi = DAG.getNode(ISD::FP_EXTEND, dl, NVT, N->getOperand(0));
17781775
}
17791776

1780-
Lo = DAG.getConstantFP(APFloat(DAG.EVTToAPFloatSemantics(NVT),
1781-
APInt(NVT.getSizeInBits(), 0)), dl, NVT);
1777+
Lo = DAG.getConstantFP(
1778+
APFloat(NVT.getFltSemantics(), APInt(NVT.getSizeInBits(), 0)), dl, NVT);
17821779

17831780
if (IsStrict)
17841781
ReplaceValueWith(SDValue(N, 1), Chain);
@@ -1934,8 +1931,8 @@ void DAGTypeLegalizer::ExpandFloatRes_LOAD(SDNode *N, SDValue &Lo,
19341931
Chain = Hi.getValue(1);
19351932

19361933
// The low part is zero.
1937-
Lo = DAG.getConstantFP(APFloat(DAG.EVTToAPFloatSemantics(NVT),
1938-
APInt(NVT.getSizeInBits(), 0)), dl, NVT);
1934+
Lo = DAG.getConstantFP(
1935+
APFloat(NVT.getFltSemantics(), APInt(NVT.getSizeInBits(), 0)), dl, NVT);
19391936

19401937
// Modified the chain - switch anything that used the old chain to use the
19411938
// new one.
@@ -1964,8 +1961,8 @@ void DAGTypeLegalizer::ExpandFloatRes_XINT_TO_FP(SDNode *N, SDValue &Lo,
19641961
// though.
19651962
if (SrcVT.bitsLE(MVT::i32)) {
19661963
// The integer can be represented exactly in an f64.
1967-
Lo = DAG.getConstantFP(APFloat(DAG.EVTToAPFloatSemantics(NVT),
1968-
APInt(NVT.getSizeInBits(), 0)), dl, NVT);
1964+
Lo = DAG.getConstantFP(
1965+
APFloat(NVT.getFltSemantics(), APInt(NVT.getSizeInBits(), 0)), dl, NVT);
19691966
if (Strict) {
19701967
Hi = DAG.getNode(N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
19711968
{Chain, Src}, Flags);

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,8 @@ bool ConstantFPSDNode::isValueValidForType(EVT VT,
132132
// convert modifies in place, so make a copy.
133133
APFloat Val2 = APFloat(Val);
134134
bool losesInfo;
135-
(void) Val2.convert(SelectionDAG::EVTToAPFloatSemantics(VT),
136-
APFloat::rmNearestTiesToEven,
137-
&losesInfo);
135+
(void)Val2.convert(VT.getFltSemantics(), APFloat::rmNearestTiesToEven,
136+
&losesInfo);
138137
return !losesInfo;
139138
}
140139

@@ -1826,7 +1825,7 @@ SDValue SelectionDAG::getConstantFP(double Val, const SDLoc &DL, EVT VT,
18261825
EltVT == MVT::f16 || EltVT == MVT::bf16) {
18271826
bool Ignored;
18281827
APFloat APF = APFloat(Val);
1829-
APF.convert(EVTToAPFloatSemantics(EltVT), APFloat::rmNearestTiesToEven,
1828+
APF.convert(EltVT.getFltSemantics(), APFloat::rmNearestTiesToEven,
18301829
&Ignored);
18311830
return getConstantFP(APF, DL, VT, isTarget);
18321831
}
@@ -6447,11 +6446,10 @@ SDValue SelectionDAG::FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL,
64476446
C->isOpaque());
64486447
case ISD::UINT_TO_FP:
64496448
case ISD::SINT_TO_FP: {
6450-
APFloat apf(EVTToAPFloatSemantics(VT),
6451-
APInt::getZero(VT.getSizeInBits()));
6452-
(void)apf.convertFromAPInt(Val, Opcode == ISD::SINT_TO_FP,
6449+
APFloat FPV(VT.getFltSemantics(), APInt::getZero(VT.getSizeInBits()));
6450+
(void)FPV.convertFromAPInt(Val, Opcode == ISD::SINT_TO_FP,
64536451
APFloat::rmNearestTiesToEven);
6454-
return getConstantFP(apf, DL, VT);
6452+
return getConstantFP(FPV, DL, VT);
64556453
}
64566454
case ISD::FP16_TO_FP:
64576455
case ISD::BF16_TO_FP: {
@@ -6462,8 +6460,8 @@ SDValue SelectionDAG::FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL,
64626460

64636461
// This can return overflow, underflow, or inexact; we don't care.
64646462
// FIXME need to be more flexible about rounding mode.
6465-
(void)FPV.convert(EVTToAPFloatSemantics(VT),
6466-
APFloat::rmNearestTiesToEven, &Ignored);
6463+
(void)FPV.convert(VT.getFltSemantics(), APFloat::rmNearestTiesToEven,
6464+
&Ignored);
64676465
return getConstantFP(FPV, DL, VT);
64686466
}
64696467
case ISD::STEP_VECTOR:
@@ -6515,7 +6513,7 @@ SDValue SelectionDAG::FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL,
65156513
bool ignored;
65166514
// This can return overflow, underflow, or inexact; we don't care.
65176515
// FIXME need to be more flexible about rounding mode.
6518-
(void)V.convert(EVTToAPFloatSemantics(VT), APFloat::rmNearestTiesToEven,
6516+
(void)V.convert(VT.getFltSemantics(), APFloat::rmNearestTiesToEven,
65196517
&ignored);
65206518
return getConstantFP(V, DL, VT);
65216519
}
@@ -6814,8 +6812,8 @@ SDValue SelectionDAG::foldConstantFPMath(unsigned Opcode, const SDLoc &DL,
68146812
bool Unused;
68156813
// This can return overflow, underflow, or inexact; we don't care.
68166814
// FIXME need to be more flexible about rounding mode.
6817-
(void) C1.convert(EVTToAPFloatSemantics(VT), APFloat::rmNearestTiesToEven,
6818-
&Unused);
6815+
(void)C1.convert(VT.getFltSemantics(), APFloat::rmNearestTiesToEven,
6816+
&Unused);
68196817
return getConstantFP(C1, DL, VT);
68206818
}
68216819

@@ -6836,7 +6834,7 @@ SDValue SelectionDAG::foldConstantFPMath(unsigned Opcode, const SDLoc &DL,
68366834
if (N1.isUndef() && N2.isUndef())
68376835
return getUNDEF(VT);
68386836
if (N1.isUndef() || N2.isUndef())
6839-
return getConstantFP(APFloat::getNaN(EVTToAPFloatSemantics(VT)), DL, VT);
6837+
return getConstantFP(APFloat::getNaN(VT.getFltSemantics()), DL, VT);
68406838
}
68416839
return SDValue();
68426840
}
@@ -7661,8 +7659,7 @@ static SDValue getMemsetValue(SDValue Value, EVT VT, SelectionDAG &DAG,
76617659
!DAG.getTargetLoweringInfo().isLegalStoreImmediate(C->getSExtValue());
76627660
return DAG.getConstant(Val, dl, VT, false, IsOpaque);
76637661
}
7664-
return DAG.getConstantFP(APFloat(DAG.EVTToAPFloatSemantics(VT), Val), dl,
7665-
VT);
7662+
return DAG.getConstantFP(APFloat(VT.getFltSemantics(), Val), dl, VT);
76667663
}
76677664

76687665
assert(Value.getValueType() == MVT::i8 && "memset with non-byte fill value?");
@@ -11952,7 +11949,7 @@ bool llvm::isNeutralConstant(unsigned Opcode, SDNodeFlags Flags, SDValue V,
1195211949
case ISD::FMAXNUM: {
1195311950
// Neutral element for fminnum is NaN, Inf or FLT_MAX, depending on FMF.
1195411951
EVT VT = V.getValueType();
11955-
const fltSemantics &Semantics = SelectionDAG::EVTToAPFloatSemantics(VT);
11952+
const fltSemantics &Semantics = VT.getFltSemantics();
1195611953
APFloat NeutralAF = !Flags.hasNoNaNs()
1195711954
? APFloat::getQNaN(Semantics)
1195811955
: !Flags.hasNoInfs()
@@ -13228,7 +13225,7 @@ SDValue SelectionDAG::getNeutralElement(unsigned Opcode, const SDLoc &DL,
1322813225
case ISD::FMINNUM:
1322913226
case ISD::FMAXNUM: {
1323013227
// Neutral element for fminnum is NaN, Inf or FLT_MAX, depending on FMF.
13231-
const fltSemantics &Semantics = EVTToAPFloatSemantics(VT);
13228+
const fltSemantics &Semantics = VT.getFltSemantics();
1323213229
APFloat NeutralAF = !Flags.hasNoNaNs() ? APFloat::getQNaN(Semantics) :
1323313230
!Flags.hasNoInfs() ? APFloat::getInf(Semantics) :
1323413231
APFloat::getLargest(Semantics);
@@ -13240,7 +13237,7 @@ SDValue SelectionDAG::getNeutralElement(unsigned Opcode, const SDLoc &DL,
1324013237
case ISD::FMINIMUM:
1324113238
case ISD::FMAXIMUM: {
1324213239
// Neutral element for fminimum is Inf or FLT_MAX, depending on FMF.
13243-
const fltSemantics &Semantics = EVTToAPFloatSemantics(VT);
13240+
const fltSemantics &Semantics = VT.getFltSemantics();
1324413241
APFloat NeutralAF = !Flags.hasNoInfs() ? APFloat::getInf(Semantics)
1324513242
: APFloat::getLargest(Semantics);
1324613243
if (Opcode == ISD::FMAXIMUM)

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,9 +2958,8 @@ bool TargetLowering::SimplifyDemandedBits(
29582958
return TLO.CombineTo(Op, TLO.DAG.getConstant(Known.One, dl, VT));
29592959
if (VT.isFloatingPoint())
29602960
return TLO.CombineTo(
2961-
Op,
2962-
TLO.DAG.getConstantFP(
2963-
APFloat(TLO.DAG.EVTToAPFloatSemantics(VT), Known.One), dl, VT));
2961+
Op, TLO.DAG.getConstantFP(APFloat(VT.getFltSemantics(), Known.One),
2962+
dl, VT));
29642963
}
29652964

29662965
// A multi use 'all demanded elts' simplify failed to find any knownbits.
@@ -7236,7 +7235,7 @@ SDValue TargetLowering::getSqrtInputTest(SDValue Op, SelectionDAG &DAG,
72367235
// Testing it with denormal inputs to avoid wrong estimate.
72377236
//
72387237
// Test = fabs(X) < SmallestNormal
7239-
const fltSemantics &FltSem = DAG.EVTToAPFloatSemantics(VT);
7238+
const fltSemantics &FltSem = VT.getFltSemantics();
72407239
APFloat SmallestNorm = APFloat::getSmallestNormalized(FltSem);
72417240
SDValue NormC = DAG.getConstantFP(SmallestNorm, DL, VT);
72427241
SDValue Fabs = DAG.getNode(ISD::FABS, DL, VT, Op);
@@ -8273,7 +8272,7 @@ bool TargetLowering::expandFP_TO_UINT(SDNode *Node, SDValue &Result,
82738272
// If the maximum float value is smaller then the signed integer range,
82748273
// the destination signmask can't be represented by the float, so we can
82758274
// just use FP_TO_SINT directly.
8276-
const fltSemantics &APFSem = DAG.EVTToAPFloatSemantics(SrcVT);
8275+
const fltSemantics &APFSem = SrcVT.getFltSemantics();
82778276
APFloat APF(APFSem, APInt::getZero(SrcVT.getScalarSizeInBits()));
82788277
APInt SignMask = APInt::getSignMask(DstVT.getScalarSizeInBits());
82798278
if (APFloat::opOverflow &
@@ -8518,8 +8517,8 @@ SDValue TargetLowering::expandFMINIMUM_FMAXIMUM(SDNode *N,
85188517
// Propagate any NaN of both operands
85198518
if (!N->getFlags().hasNoNaNs() &&
85208519
(!DAG.isKnownNeverNaN(RHS) || !DAG.isKnownNeverNaN(LHS))) {
8521-
ConstantFP *FPNaN = ConstantFP::get(
8522-
*DAG.getContext(), APFloat::getNaN(DAG.EVTToAPFloatSemantics(VT)));
8520+
ConstantFP *FPNaN = ConstantFP::get(*DAG.getContext(),
8521+
APFloat::getNaN(VT.getFltSemantics()));
85238522
MinMax = DAG.getSelect(DL, VT, DAG.getSetCC(DL, CCVT, LHS, RHS, ISD::SETUO),
85248523
DAG.getConstantFP(*FPNaN, DL, VT), MinMax, Flags);
85258524
}
@@ -11263,8 +11262,9 @@ SDValue TargetLowering::expandFP_TO_INT_SAT(SDNode *Node,
1126311262
SrcVT = Src.getValueType();
1126411263
}
1126511264

11266-
APFloat MinFloat(DAG.EVTToAPFloatSemantics(SrcVT));
11267-
APFloat MaxFloat(DAG.EVTToAPFloatSemantics(SrcVT));
11265+
const fltSemantics &Sem = SrcVT.getFltSemantics();
11266+
APFloat MinFloat(Sem);
11267+
APFloat MaxFloat(Sem);
1126811268

1126911269
APFloat::opStatus MinStatus =
1127011270
MinFloat.convertFromAPInt(MinInt, IsSigned, APFloat::rmTowardZero);

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11471,8 +11471,7 @@ static SDValue getEstimate(const AArch64Subtarget *ST, unsigned Opcode,
1147111471
// the result for float (23 mantissa bits) is 2 and for double (52
1147211472
// mantissa bits) is 3.
1147311473
constexpr unsigned AccurateBits = 8;
11474-
unsigned DesiredBits =
11475-
APFloat::semanticsPrecision(DAG.EVTToAPFloatSemantics(VT));
11474+
unsigned DesiredBits = APFloat::semanticsPrecision(VT.getFltSemantics());
1147611475
ExtraSteps = DesiredBits <= AccurateBits
1147711476
? 0
1147811477
: Log2_64_Ceil(DesiredBits) - Log2_64_Ceil(AccurateBits);

llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,7 +2590,7 @@ SDValue AMDGPUTargetLowering::getIsLtSmallestNormal(SelectionDAG &DAG,
25902590
SDNodeFlags Flags) const {
25912591
SDLoc SL(Src);
25922592
EVT VT = Src.getValueType();
2593-
const fltSemantics &Semantics = SelectionDAG::EVTToAPFloatSemantics(VT);
2593+
const fltSemantics &Semantics = VT.getFltSemantics();
25942594
SDValue SmallestNormal =
25952595
DAG.getConstantFP(APFloat::getSmallestNormalized(Semantics), SL, VT);
25962596

@@ -2607,7 +2607,7 @@ SDValue AMDGPUTargetLowering::getIsFinite(SelectionDAG &DAG, SDValue Src,
26072607
SDNodeFlags Flags) const {
26082608
SDLoc SL(Src);
26092609
EVT VT = Src.getValueType();
2610-
const fltSemantics &Semantics = SelectionDAG::EVTToAPFloatSemantics(VT);
2610+
const fltSemantics &Semantics = VT.getFltSemantics();
26112611
SDValue Inf = DAG.getConstantFP(APFloat::getInf(Semantics), SL, VT);
26122612

26132613
SDValue Fabs = DAG.getNode(ISD::FABS, SL, VT, Src, Flags);

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10872,8 +10872,8 @@ SDValue SITargetLowering::LowerFFREXP(SDValue Op, SelectionDAG &DAG) const {
1087210872

1087310873
if (Subtarget->hasFractBug()) {
1087410874
SDValue Fabs = DAG.getNode(ISD::FABS, dl, VT, Val);
10875-
SDValue Inf = DAG.getConstantFP(
10876-
APFloat::getInf(SelectionDAG::EVTToAPFloatSemantics(VT)), dl, VT);
10875+
SDValue Inf =
10876+
DAG.getConstantFP(APFloat::getInf(VT.getFltSemantics()), dl, VT);
1087710877

1087810878
SDValue IsFinite = DAG.getSetCC(dl, MVT::i1, Fabs, Inf, ISD::SETOLT);
1087910879
SDValue Zero = DAG.getConstant(0, dl, InstrExpVT);
@@ -12578,9 +12578,8 @@ SDValue SITargetLowering::performRcpCombine(SDNode *N,
1257812578
SDValue N0 = N->getOperand(0);
1257912579

1258012580
if (N0.isUndef()) {
12581-
return DCI.DAG.getConstantFP(
12582-
APFloat::getQNaN(SelectionDAG::EVTToAPFloatSemantics(VT)), SDLoc(N),
12583-
VT);
12581+
return DCI.DAG.getConstantFP(APFloat::getQNaN(VT.getFltSemantics()),
12582+
SDLoc(N), VT);
1258412583
}
1258512584

1258612585
if (VT == MVT::f32 && (N0.getOpcode() == ISD::UINT_TO_FP ||
@@ -12964,7 +12963,7 @@ SDValue SITargetLowering::performFCanonicalizeCombine(
1296412963

1296512964
// fcanonicalize undef -> qnan
1296612965
if (N0.isUndef()) {
12967-
APFloat QNaN = APFloat::getQNaN(SelectionDAG::EVTToAPFloatSemantics(VT));
12966+
APFloat QNaN = APFloat::getQNaN(VT.getFltSemantics());
1296812967
return DAG.getConstantFP(QNaN, SDLoc(N), VT);
1296912968
}
1297012969

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2977,7 +2977,7 @@ lowerVectorFTRUNC_FCEIL_FFLOOR_FROUND(SDValue Op, SelectionDAG &DAG,
29772977
// Determine the largest integer that can be represented exactly. This and
29782978
// values larger than it don't have any fractional bits so don't need to
29792979
// be converted.
2980-
const fltSemantics &FltSem = DAG.EVTToAPFloatSemantics(ContainerVT);
2980+
const fltSemantics &FltSem = ContainerVT.getFltSemantics();
29812981
unsigned Precision = APFloat::semanticsPrecision(FltSem);
29822982
APFloat MaxVal = APFloat(FltSem);
29832983
MaxVal.convertFromAPInt(APInt::getOneBitSet(Precision, Precision - 1),
@@ -3087,7 +3087,7 @@ lowerVectorStrictFTRUNC_FCEIL_FFLOOR_FROUND(SDValue Op, SelectionDAG &DAG,
30873087
// Determine the largest integer that can be represented exactly. This and
30883088
// values larger than it don't have any fractional bits so don't need to
30893089
// be converted.
3090-
const fltSemantics &FltSem = DAG.EVTToAPFloatSemantics(ContainerVT);
3090+
const fltSemantics &FltSem = ContainerVT.getFltSemantics();
30913091
unsigned Precision = APFloat::semanticsPrecision(FltSem);
30923092
APFloat MaxVal = APFloat(FltSem);
30933093
MaxVal.convertFromAPInt(APInt::getOneBitSet(Precision, Precision - 1),
@@ -3167,7 +3167,7 @@ lowerFTRUNC_FCEIL_FFLOOR_FROUND(SDValue Op, SelectionDAG &DAG,
31673167
// Create an integer the size of the mantissa with the MSB set. This and all
31683168
// values larger than it don't have any fractional bits so don't need to be
31693169
// converted.
3170-
const fltSemantics &FltSem = DAG.EVTToAPFloatSemantics(VT);
3170+
const fltSemantics &FltSem = VT.getFltSemantics();
31713171
unsigned Precision = APFloat::semanticsPrecision(FltSem);
31723172
APFloat MaxVal = APFloat(FltSem);
31733173
MaxVal.convertFromAPInt(APInt::getOneBitSet(Precision, Precision - 1),
@@ -9598,8 +9598,7 @@ SDValue RISCVTargetLowering::lowerFPVECREDUCE(SDValue Op,
95989598
DAG.getConstant(0, DL, XLenVT), ISD::SETEQ);
95999599
return DAG.getSelect(
96009600
DL, ResVT, NoNaNs, Res,
9601-
DAG.getConstantFP(APFloat::getNaN(DAG.EVTToAPFloatSemantics(ResVT)), DL,
9602-
ResVT));
9601+
DAG.getConstantFP(APFloat::getNaN(ResVT.getFltSemantics()), DL, ResVT));
96039602
}
96049603

96059604
SDValue RISCVTargetLowering::lowerVPREDUCE(SDValue Op,
@@ -9648,8 +9647,7 @@ SDValue RISCVTargetLowering::lowerVPREDUCE(SDValue Op,
96489647
MVT ResVT = Res.getSimpleValueType();
96499648
return DAG.getSelect(
96509649
DL, ResVT, NoNaNs, Res,
9651-
DAG.getConstantFP(APFloat::getNaN(DAG.EVTToAPFloatSemantics(ResVT)), DL,
9652-
ResVT));
9650+
DAG.getConstantFP(APFloat::getNaN(ResVT.getFltSemantics()), DL, ResVT));
96539651
}
96549652

96559653
SDValue RISCVTargetLowering::lowerINSERT_SUBVECTOR(SDValue Op,

0 commit comments

Comments
 (0)