[loongarch][DAG][FREEZE] Fix crash when FREEZE a half(f16) type on loongarch by yxd-ym · Pull Request #107791 · llvm/llvm-project

added 2 commits

September 8, 2024 17:47

arsenm

@yxd-ym

wangleiat

@yxd-ym

llvmbot pushed a commit to llvmbot/llvm-project that referenced this pull request

Sep 18, 2024
…ongarch (llvm#107791)

For zig with LLVM 19.1.0rc4, we are seeing the following error when
bootstrapping a `loongarch64-linux-musl` target.

ziglang/zig-bootstrap#164 (comment)

It seems that this issue is caused by `PromoteFloatResult` is not
handling FREEZE OP on loongarch.

Here is the reproduction of the error: https://godbolt.org/z/PPfvWjjG5

~~This patch adds the FREEZE OP handling with `PromoteFloatRes_UnaryOp`
and adds a test case.~~

This patch changes loongarch's way of floating point promotion to soft
promotion to avoid this problem.

See: loongarch's handling of `half`:
- llvm#93894
- llvm#94456

Also see: other float promotion FREEZE handling
-
llvm@0019c2f

(cherry picked from commit 13280d9)

andrewrk added a commit to ziglang/zig-bootstrap that referenced this pull request

Sep 18, 2024

@andrewrk

This was referenced

Sep 20, 2024

@nikic nikic mentioned this pull request

Sep 20, 2024

heiher pushed a commit to llvmbot/llvm-project that referenced this pull request

Oct 19, 2024
…ongarch (llvm#107791)

For zig with LLVM 19.1.0rc4, we are seeing the following error when
bootstrapping a `loongarch64-linux-musl` target.

ziglang/zig-bootstrap#164 (comment)

It seems that this issue is caused by `PromoteFloatResult` is not
handling FREEZE OP on loongarch.

Here is the reproduction of the error: https://godbolt.org/z/PPfvWjjG5

~~This patch adds the FREEZE OP handling with `PromoteFloatRes_UnaryOp`
and adds a test case.~~

This patch changes loongarch's way of floating point promotion to soft
promotion to avoid this problem.

See: loongarch's handling of `half`:
- llvm#93894
- llvm#94456

Also see: other float promotion FREEZE handling
-
llvm@0019c2f

(cherry picked from commit 13280d9)

This was referenced

Nov 18, 2024

andrewrk added a commit to ziglang/zig-bootstrap that referenced this pull request

Jan 20, 2025

tgross35 added a commit to tgross35/llvm-project that referenced this pull request

Sep 10, 2025
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 in
f0231b6 ("[MIPS] Use softPromoteHalf legalization for fp16 rather
than PromoteFloat (llvm#110199)") and for Loongarch in 13280d9
("[loongarch][DAG][FREEZE] Fix crash when FREEZE a half(f16) type on
loongarch (llvm#107791)").

[1]: llvm#97975

tgross35 added a commit to tgross35/llvm-project that referenced this pull request

Jan 8, 2026
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 in
f0231b6 ("[MIPS] Use softPromoteHalf legalization for fp16 rather
than PromoteFloat (llvm#110199)") and for Loongarch in 13280d9
("[loongarch][DAG][FREEZE] Fix crash when FREEZE a half(f16) type on
loongarch (llvm#107791)").

[1]: llvm#97975