Skip to content

Commit 4019b70

Browse files
committed
Remove NoNaNsFPMath in visitFSUB
1 parent 3eb2a9e commit 4019b70

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17973,7 +17973,6 @@ SDValue DAGCombiner::visitFSUB(SDNode *N) {
1797317973
ConstantFPSDNode *N1CFP = isConstOrConstSplatFP(N1, true);
1797417974
EVT VT = N->getValueType(0);
1797517975
SDLoc DL(N);
17976-
const TargetOptions &Options = DAG.getTarget().Options;
1797717976
const SDNodeFlags Flags = N->getFlags();
1797817977
SelectionDAG::FlagInserter FlagsInserter(DAG, N);
1797917978

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

1800218001
if (N0 == N1) {
1800318002
// (fsub x, x) -> 0.0
18004-
if (Options.NoNaNsFPMath || Flags.hasNoNaNs())
18003+
if (Flags.hasNoNaNs())
1800518004
return DAG.getConstantFP(0.0f, DL, VT);
1800618005
}
1800718006

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)