Skip to content

Commit e2040f5

Browse files
authored
[RISCV][GISel] Remove shouldBeInFConstantPool. Always convert G_FCONSTANT to G_CONSTANT without F/D. (#158717)
We can unconditionally convert to G_CONSTANT. G_CONSTANT will go through its own legalization and call the integer shouldBeInConstantPool.
1 parent 0d92775 commit e2040f5

File tree

2 files changed

+1
-15
lines changed

2 files changed

+1
-15
lines changed

llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -871,17 +871,6 @@ bool RISCVLegalizerInfo::shouldBeInConstantPool(const APInt &APImm,
871871
return !(!SeqLo.empty() && (SeqLo.size() + 2) <= STI.getMaxBuildIntsCost());
872872
}
873873

874-
bool RISCVLegalizerInfo::shouldBeInFConstantPool(const APFloat &APF) const {
875-
[[maybe_unused]] unsigned Size = APF.getSizeInBits(APF.getSemantics());
876-
assert((Size == 32 || Size == 64) && "Only support f32 and f64");
877-
878-
int64_t Imm = APF.bitcastToAPInt().getSExtValue();
879-
RISCVMatInt::InstSeq Seq = RISCVMatInt::generateInstSeq(Imm, STI);
880-
if (Seq.size() <= STI.getMaxBuildIntsCost())
881-
return false;
882-
return true;
883-
}
884-
885874
bool RISCVLegalizerInfo::legalizeVScale(MachineInstr &MI,
886875
MachineIRBuilder &MIB) const {
887876
const LLT XLenTy(STI.getXLenVT());
@@ -1372,9 +1361,7 @@ bool RISCVLegalizerInfo::legalizeCustom(
13721361
case TargetOpcode::G_ABS:
13731362
return Helper.lowerAbsToMaxNeg(MI);
13741363
case TargetOpcode::G_FCONSTANT: {
1375-
const APFloat FVal = MI.getOperand(1).getFPImm()->getValueAPF();
1376-
if (shouldBeInFConstantPool(FVal))
1377-
return Helper.lowerFConstant(MI);
1364+
const APFloat &FVal = MI.getOperand(1).getFPImm()->getValueAPF();
13781365

13791366
// Convert G_FCONSTANT to G_CONSTANT.
13801367
Register DstReg = MI.getOperand(0).getReg();

llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class RISCVLegalizerInfo : public LegalizerInfo {
3939

4040
private:
4141
bool shouldBeInConstantPool(const APInt &APImm, bool ShouldOptForSize) const;
42-
bool shouldBeInFConstantPool(const APFloat &APImm) const;
4342
bool legalizeShlAshrLshr(MachineInstr &MI, MachineIRBuilder &MIRBuilder,
4443
GISelChangeObserver &Observer) const;
4544

0 commit comments

Comments
 (0)