Skip to content

Commit 2428193

Browse files
committed
Remove UnsafeFPMath uses
1 parent 8bacfb2 commit 2428193

File tree

5 files changed

+6
-33
lines changed

5 files changed

+6
-33
lines changed

llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,6 @@ bool NVPTXDAGToDAGISel::allowFMA() const {
8282
return TL->allowFMA(*MF, OptLevel);
8383
}
8484

85-
bool NVPTXDAGToDAGISel::allowUnsafeFPMath() const {
86-
const NVPTXTargetLowering *TL = Subtarget->getTargetLowering();
87-
return TL->allowUnsafeFPMath(*MF);
88-
}
89-
9085
bool NVPTXDAGToDAGISel::doRsqrtOpt() const { return EnableRsqrtOpt; }
9186

9287
/// Select - Select instructions not customized! Used for

llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class LLVM_LIBRARY_VISIBILITY NVPTXDAGToDAGISel : public SelectionDAGISel {
4444
bool usePrecSqrtF32(const SDNode *N) const;
4545
bool useF32FTZ() const;
4646
bool allowFMA() const;
47-
bool allowUnsafeFPMath() const;
4847
bool doRsqrtOpt() const;
4948

5049
NVPTXScopes Scopes{};

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ NVPTXTargetLowering::getDivF32Level(const MachineFunction &MF,
125125
if (UsePrecDivF32.getNumOccurrences() > 0)
126126
return UsePrecDivF32;
127127

128-
// Otherwise, use div.approx if fast math is enabled
129-
if (allowUnsafeFPMath(MF))
130-
return NVPTX::DivPrecisionLevel::Approx;
131-
132128
const SDNodeFlags Flags = N.getFlags();
133129
if (Flags.hasApproximateFuncs())
134130
return NVPTX::DivPrecisionLevel::Approx;
@@ -142,10 +138,6 @@ bool NVPTXTargetLowering::usePrecSqrtF32(const MachineFunction &MF,
142138
if (UsePrecSqrtF32.getNumOccurrences() > 0)
143139
return UsePrecSqrtF32;
144140

145-
// Otherwise, use sqrt.approx if fast math is enabled
146-
if (allowUnsafeFPMath(MF))
147-
return false;
148-
149141
if (N) {
150142
const SDNodeFlags Flags = N->getFlags();
151143
if (Flags.hasApproximateFuncs())
@@ -2687,8 +2679,7 @@ static SDValue lowerROT(SDValue Op, SelectionDAG &DAG) {
26872679
SDLoc(Op), Opcode, DAG);
26882680
}
26892681

2690-
static SDValue lowerFREM(SDValue Op, SelectionDAG &DAG,
2691-
bool AllowUnsafeFPMath) {
2682+
static SDValue lowerFREM(SDValue Op, SelectionDAG &DAG) {
26922683
// Lower (frem x, y) into (sub x, (mul (ftrunc (div x, y)) y)),
26932684
// i.e. "poor man's fmod()". When y is infinite, x is returned. This matches
26942685
// the semantics of LLVM's frem.
@@ -2705,7 +2696,7 @@ static SDValue lowerFREM(SDValue Op, SelectionDAG &DAG,
27052696
SDValue Sub = DAG.getNode(ISD::FSUB, DL, Ty, X, Mul,
27062697
Flags | SDNodeFlags::AllowContract);
27072698

2708-
if (AllowUnsafeFPMath || Flags.hasNoInfs())
2699+
if (Flags.hasNoInfs())
27092700
return Sub;
27102701

27112702
// If Y is infinite, return X
@@ -2845,7 +2836,7 @@ NVPTXTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
28452836
case ISD::CTLZ:
28462837
return lowerCTLZCTPOP(Op, DAG);
28472838
case ISD::FREM:
2848-
return lowerFREM(Op, DAG, allowUnsafeFPMath(DAG.getMachineFunction()));
2839+
return lowerFREM(Op, DAG);
28492840

28502841
default:
28512842
llvm_unreachable("Custom lowering not defined for operation");
@@ -4718,17 +4709,7 @@ bool NVPTXTargetLowering::allowFMA(MachineFunction &MF,
47184709
if (MF.getTarget().Options.AllowFPOpFusion == FPOpFusion::Fast)
47194710
return true;
47204711

4721-
return allowUnsafeFPMath(MF);
4722-
}
4723-
4724-
bool NVPTXTargetLowering::allowUnsafeFPMath(const MachineFunction &MF) const {
4725-
// Honor TargetOptions flags that explicitly say unsafe math is okay.
4726-
if (MF.getTarget().Options.UnsafeFPMath)
4727-
return true;
4728-
4729-
// Allow unsafe math if unsafe-fp-math attribute explicitly says so.
4730-
const Function &F = MF.getFunction();
4731-
return F.getFnAttribute("unsafe-fp-math").getValueAsBool();
4712+
return false;
47324713
}
47334714

47344715
static bool isConstZero(const SDValue &Operand) {

llvm/lib/Target/NVPTX/NVPTXISelLowering.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ class NVPTXTargetLowering : public TargetLowering {
215215
unsigned combineRepeatedFPDivisors() const override { return 2; }
216216

217217
bool allowFMA(MachineFunction &MF, CodeGenOptLevel OptLevel) const;
218-
bool allowUnsafeFPMath(const MachineFunction &MF) const;
219218

220219
bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
221220
EVT) const override {

llvm/lib/Target/NVPTX/NVPTXInstrInfo.td

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,9 +1181,8 @@ defm FMA_F64 : FMA<F64RT, allow_ftz = false>;
11811181
// sin/cos/tanh
11821182

11831183
class UnaryOpAllowsApproxFn<SDPatternOperator operator>
1184-
: PatFrag<(ops node:$A),
1185-
(operator node:$A), [{
1186-
return allowUnsafeFPMath() || N->getFlags().hasApproximateFuncs();
1184+
: PatFrag<(ops node:$A), (operator node:$A), [{
1185+
return N->getFlags().hasApproximateFuncs();
11871186
}]>;
11881187

11891188
def SIN_APPROX_f32 :

0 commit comments

Comments
 (0)