Skip to content

Commit 17a2465

Browse files
paperchalicegithub-actions[bot]
authored andcommitted
Automerge: [DAGCombiner] Remove NoNaNsFPMath uses (#163504)
Users should use `nnan` flag instead.
2 parents 39f7e78 + bfee9db commit 17a2465

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17759,7 +17759,6 @@ SDValue DAGCombiner::visitFADD(SDNode *N) {
1775917759
bool N1CFP = DAG.isConstantFPBuildVectorOrConstantFP(N1);
1776017760
EVT VT = N->getValueType(0);
1776117761
SDLoc DL(N);
17762-
const TargetOptions &Options = DAG.getTarget().Options;
1776317762
SDNodeFlags Flags = N->getFlags();
1776417763
SelectionDAG::FlagInserter FlagsInserter(DAG, N);
1776517764

@@ -17825,7 +17824,7 @@ SDValue DAGCombiner::visitFADD(SDNode *N) {
1782517824
bool AllowNewConst = (Level < AfterLegalizeDAG);
1782617825

1782717826
// If nnan is enabled, fold lots of things.
17828-
if ((Options.NoNaNsFPMath || Flags.hasNoNaNs()) && AllowNewConst) {
17827+
if (Flags.hasNoNaNs() && AllowNewConst) {
1782917828
// If allowed, fold (fadd (fneg x), x) -> 0.0
1783017829
if (N0.getOpcode() == ISD::FNEG && N0.getOperand(0) == N1)
1783117830
return DAG.getConstantFP(0.0, DL, VT);
@@ -17974,7 +17973,6 @@ SDValue DAGCombiner::visitFSUB(SDNode *N) {
1797417973
ConstantFPSDNode *N1CFP = isConstOrConstSplatFP(N1, true);
1797517974
EVT VT = N->getValueType(0);
1797617975
SDLoc DL(N);
17977-
const TargetOptions &Options = DAG.getTarget().Options;
1797817976
const SDNodeFlags Flags = N->getFlags();
1797917977
SelectionDAG::FlagInserter FlagsInserter(DAG, N);
1798017978

@@ -18002,7 +18000,7 @@ SDValue DAGCombiner::visitFSUB(SDNode *N) {
1800218000

1800318001
if (N0 == N1) {
1800418002
// (fsub x, x) -> 0.0
18005-
if (Options.NoNaNsFPMath || Flags.hasNoNaNs())
18003+
if (Flags.hasNoNaNs())
1800618004
return DAG.getConstantFP(0.0f, DL, VT);
1800718005
}
1800818006

@@ -18313,7 +18311,6 @@ template <class MatchContextClass> SDValue DAGCombiner::visitFMA(SDNode *N) {
1831318311
ConstantFPSDNode *N2CFP = dyn_cast<ConstantFPSDNode>(N2);
1831418312
EVT VT = N->getValueType(0);
1831518313
SDLoc DL(N);
18316-
const TargetOptions &Options = DAG.getTarget().Options;
1831718314
// FMA nodes have flags that propagate to the created nodes.
1831818315
SelectionDAG::FlagInserter FlagsInserter(DAG, N);
1831918316
MatchContextClass matcher(DAG, TLI, N);
@@ -18339,8 +18336,7 @@ template <class MatchContextClass> SDValue DAGCombiner::visitFMA(SDNode *N) {
1833918336
return matcher.getNode(ISD::FMA, DL, VT, NegN0, NegN1, N2);
1834018337
}
1834118338

18342-
if ((Options.NoNaNsFPMath && N->getFlags().hasNoInfs()) ||
18343-
(N->getFlags().hasNoNaNs() && N->getFlags().hasNoInfs())) {
18339+
if (N->getFlags().hasNoNaNs() && N->getFlags().hasNoInfs()) {
1834418340
if (N->getFlags().hasNoSignedZeros() ||
1834518341
(N2CFP && !N2CFP->isExactlyValue(-0.0))) {
1834618342
if (N0CFP && N0CFP->isZero())

llvm/test/CodeGen/ARM/nnan-fsub.ll

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
; RUN: llc -mcpu=cortex-a9 < %s | FileCheck -check-prefix=SAFE %s
2-
; RUN: llc -mcpu=cortex-a9 --enable-no-nans-fp-math < %s | FileCheck -check-prefix=FAST %s
1+
; RUN: llc -mcpu=cortex-a9 < %s | FileCheck %s
32

43
target triple = "armv7-apple-ios"
54

6-
; SAFE: test
7-
; FAST: test
5+
; CHECK-LABEL: test
86
define float @test(float %x, float %y) {
97
entry:
10-
; SAFE: vmul.f32
11-
; SAFE: vsub.f32
12-
; FAST: mov r0, #0
8+
; CHECK: vmul.f32
9+
; CHECK-NEXT: vsub.f32
1310
%0 = fmul float %x, %y
1411
%1 = fsub float %0, %0
1512
ret float %1
1613
}
1714

18-
15+
; CHECK-LABEL: test_nnan
16+
define float @test_nnan(float %x, float %y) {
17+
entry:
18+
; CHECK: mov r0, #0
19+
%0 = fmul float %x, %y
20+
%1 = fsub nnan float %0, %0
21+
ret float %1
22+
}

0 commit comments

Comments
 (0)