Skip to content

Commit 260ff02

Browse files
committed
[MIPS] Fix miscompiles consecutive half operations
Use softPromoteHalf legalization for fp16 rather than PromoteFloat. Fix llvm#97975.
1 parent 9b5a303 commit 260ff02

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

llvm/lib/Target/Mips/MipsISelLowering.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,11 @@ class TargetRegisterClass;
369369
return getTargetMachine().isPositionIndependent();
370370
}
371371

372-
CCAssignFn *CCAssignFnForCall() const;
372+
CCAssignFn *CCAssignFnForCall() const;
373373

374-
CCAssignFn *CCAssignFnForReturn() const;
374+
CCAssignFn *CCAssignFnForReturn() const;
375+
376+
bool softPromoteHalfType() const override { return true; }
375377

376378
protected:
377379
SDValue getGlobalReg(SelectionDAG &DAG, EVT Ty) const;
@@ -390,8 +392,8 @@ class TargetRegisterClass;
390392
DAG.getLoad(Ty, DL, DAG.getEntryNode(), GOT,
391393
MachinePointerInfo::getGOT(DAG.getMachineFunction()));
392394
unsigned LoFlag = IsN32OrN64 ? MipsII::MO_GOT_OFST : MipsII::MO_ABS_LO;
393-
SDValue Lo = DAG.getNode(MipsISD::Lo, DL, Ty,
394-
getTargetNode(N, Ty, DAG, LoFlag));
395+
SDValue Lo =
396+
DAG.getNode(MipsISD::Lo, DL, Ty, getTargetNode(N, Ty, DAG, LoFlag));
395397
return DAG.getNode(ISD::ADD, DL, Ty, Load, Lo);
396398
}
397399

llvm/test/CodeGen/Mips/fp16-promote.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ define <4 x float> @test_vec_fpext_float(ptr %p) #0 {
6262
; CHECK-LIBCALL-LABEL: test_vec_fpext_double:
6363
; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
6464
; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
65-
; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
6665
; CHECK-LIBCALL: cvt.d.s
66+
; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
6767
; CHECK-LIBCALL: cvt.d.s
6868
; CHECK-LIBCALL: cvt.d.s
6969
; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)

0 commit comments

Comments
 (0)