Skip to content

Commit a93edf9

Browse files
committed
[PowerPC] Change half to use soft promotion rather than PromoteFloat
On PowerPC targets, `half` uses the default legalization of promoting to a `f32`. However, this has some fundamental issues related to inability to round trip. Resolve this by switching to the soft legalization, which passes `f16` as an `i16`. The PowerPC ABI Specification does not define a `_Float16` type, so the calling convention changes are acceptable. Fixes the PowerPC portion of [1]. A similar change was done for MIPS [2] and Loongarch [3]. [1]: llvm#97975 [2]: llvm#110199 [3]: llvm#107791
1 parent 8d154f5 commit a93edf9

File tree

3 files changed

+253
-534
lines changed

3 files changed

+253
-534
lines changed

llvm/docs/ReleaseNotes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ Changes to the MIPS Backend
101101
Changes to the PowerPC Backend
102102
------------------------------
103103

104+
* `half` now uses a soft float ABI, which works correctly in more cases.
105+
104106
Changes to the RISC-V Backend
105107
-----------------------------
106108

llvm/lib/Target/PowerPC/PPCISelLowering.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,8 @@ namespace llvm {
801801

802802
bool useSoftFloat() const override;
803803

804+
bool softPromoteHalfType() const override { return true; }
805+
804806
bool hasSPE() const;
805807

806808
MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {

0 commit comments

Comments
 (0)