Skip to content

Commit a5fd28e

Browse files
committed
[MIPS] Fix -msingle-float doesn't work with double on O32
Skip the following function 'CustomLowerNode' when the operand had done `SoftenFloatResult`. Fix #93052
1 parent 41491c7 commit a5fd28e

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2760,9 +2760,19 @@ void DAGTypeLegalizer::ExpandIntegerResult(SDNode *N, unsigned ResNo) {
27602760
LLVM_DEBUG(dbgs() << "Expand integer result: "; N->dump(&DAG));
27612761
SDValue Lo, Hi;
27622762
Lo = Hi = SDValue();
2763+
bool NeedCustomLower = true;
2764+
2765+
// Skip the following function 'CustomLowerNode' when the operand had done
2766+
// `SoftenFloatResult`.
2767+
if (N->getOpcode() == ISD::BITCAST &&
2768+
getTypeAction(N->getOperand(0).getValueType()) ==
2769+
TargetLowering::TypeSoftenFloat &&
2770+
N->getValueType(ResNo) ==
2771+
GetSoftenedFloat(N->getOperand(0)).getValueType())
2772+
NeedCustomLower = false;
27632773

27642774
// See if the target wants to custom expand this node.
2765-
if (CustomLowerNode(N, N->getValueType(ResNo), true))
2775+
if (NeedCustomLower && CustomLowerNode(N, N->getValueType(ResNo), true))
27662776
return;
27672777

27682778
switch (N->getOpcode()) {
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
; RUN: llc -march=mips -mattr=single-float < %s | FileCheck %s
1+
; RUN: llc -march=mips -mcpu=mips32 -mattr=single-float -O2 < %s | FileCheck %s
2+
; RUN: llc -march=mips -mcpu=mips32r2 -mattr=single-float -O2 < %s | FileCheck %s
23

34
define double @dofloat(double %a, double %b) nounwind {
5+
; CHECK-LABEL: dofloat:
6+
; CHECK: # %bb.0: # %entry
7+
; CHECK-NEXT: addiu $sp, $sp, -24
8+
; CHECK-NEXT: sw $ra, 20($sp)
9+
; CHECK-NEXT: jal __adddf3
10+
; CHECK-NEXT: nop
11+
; CHECK-NEXT: lw $ra, 20($sp)
12+
; CHECK-NEXT: jr $ra
13+
; CHECK-NEXT: addiu $sp, $sp, 24
14+
415
entry:
5-
; CHECK: __adddf3
6-
fadd double %a, %b ; <double>:0 [#uses=1]
7-
ret double %0
16+
fadd double %a, %b ; <double>:0 [#uses=1]
17+
ret double %0
818
}

0 commit comments

Comments
 (0)