Skip to content

Commit 525090e

Browse files
authored
Revert "[MIPS]Fix QNaNs in the MIPS legacy NaN encodings" (llvm#150773)
Reverts llvm#139829. We can't just randomly change the value of constants during lowering. Fixes llvm#149295.
1 parent 44ff1ed commit 525090e

File tree

4 files changed

+25
-44
lines changed

4 files changed

+25
-44
lines changed

llvm/lib/Target/Mips/MipsISelLowering.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,6 @@ MipsTargetLowering::MipsTargetLowering(const MipsTargetMachine &TM,
522522

523523
setOperationAction(ISD::TRAP, MVT::Other, Legal);
524524

525-
setOperationAction(ISD::ConstantFP, MVT::f32, Custom);
526-
setOperationAction(ISD::ConstantFP, MVT::f64, Custom);
527-
528525
setTargetDAGCombine({ISD::SDIVREM, ISD::UDIVREM, ISD::SELECT, ISD::AND,
529526
ISD::OR, ISD::ADD, ISD::SUB, ISD::AssertZext, ISD::SHL,
530527
ISD::SIGN_EXTEND});
@@ -1360,8 +1357,6 @@ LowerOperation(SDValue Op, SelectionDAG &DAG) const
13601357
case ISD::FP_TO_SINT: return lowerFP_TO_SINT(Op, DAG);
13611358
case ISD::READCYCLECOUNTER:
13621359
return lowerREADCYCLECOUNTER(Op, DAG);
1363-
case ISD::ConstantFP:
1364-
return lowerConstantFP(Op, DAG);
13651360
}
13661361
return SDValue();
13671362
}
@@ -3019,30 +3014,6 @@ SDValue MipsTargetLowering::lowerFP_TO_SINT(SDValue Op,
30193014
return DAG.getNode(ISD::BITCAST, SDLoc(Op), Op.getValueType(), Trunc);
30203015
}
30213016

3022-
SDValue MipsTargetLowering::lowerConstantFP(SDValue Op,
3023-
SelectionDAG &DAG) const {
3024-
SDLoc DL(Op);
3025-
EVT VT = Op.getSimpleValueType();
3026-
SDNode *N = Op.getNode();
3027-
ConstantFPSDNode *CFP = cast<ConstantFPSDNode>(N);
3028-
3029-
if (!CFP->isNaN() || Subtarget.isNaN2008()) {
3030-
return SDValue();
3031-
}
3032-
3033-
APFloat NaNValue = CFP->getValueAPF();
3034-
auto &Sem = NaNValue.getSemantics();
3035-
3036-
// The MSB of the mantissa should be zero for QNaNs in the MIPS legacy NaN
3037-
// encodings, and one for sNaNs. Check every NaN constants and make sure
3038-
// they are correctly encoded for legacy encodings.
3039-
if (!NaNValue.isSignaling()) {
3040-
APFloat RealQNaN = NaNValue.getSNaN(Sem);
3041-
return DAG.getConstantFP(RealQNaN, DL, VT);
3042-
}
3043-
return SDValue();
3044-
}
3045-
30463017
//===----------------------------------------------------------------------===//
30473018
// Calling Convention Implementation
30483019
//===----------------------------------------------------------------------===//

llvm/lib/Target/Mips/MipsISelLowering.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ class TargetRegisterClass;
592592
SDValue lowerEH_DWARF_CFA(SDValue Op, SelectionDAG &DAG) const;
593593
SDValue lowerFP_TO_SINT(SDValue Op, SelectionDAG &DAG) const;
594594
SDValue lowerREADCYCLECOUNTER(SDValue Op, SelectionDAG &DAG) const;
595-
SDValue lowerConstantFP(SDValue Op, SelectionDAG &DAG) const;
596595

597596
/// isEligibleForTailCallOptimization - Check whether the call is eligible
598597
/// for tail call optimization.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
; RUN: llc -mtriple=mips-linux-gnu -mattr=-nan2008 < %s | FileCheck %s
2+
; RUN: llc -mtriple=mips-linux-gnu -mattr=+nan2008 < %s | FileCheck %s
3+
4+
; Make sure that lowering does not corrupt the value of NaN values,
5+
; regardless of what the NaN mode is.
6+
7+
define float @test1() {
8+
; CHECK: .4byte 0x7fc00000
9+
ret float bitcast (i32 u0x7fc00000 to float)
10+
}
11+
12+
define float @test2() {
13+
; CHECK: .4byte 0x7fc00001
14+
ret float bitcast (i32 u0x7fc00001 to float)
15+
}
16+
17+
define float @test3() {
18+
; CHECK: .4byte 0x7f800000
19+
ret float bitcast (i32 u0x7f800000 to float)
20+
}
21+
22+
define float @test4() {
23+
; CHECK: .4byte 0x7f800001
24+
ret float bitcast (i32 u0x7f800001 to float)
25+
}

llvm/test/CodeGen/Mips/qnan.ll

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)