Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerPC fp128 -> half uses __trunctfhf2 but should be __trunckfhf2 #98126

Open
tgross35 opened this issue Jul 9, 2024 · 1 comment
Open

PowerPC fp128 -> half uses __trunctfhf2 but should be __trunckfhf2 #98126

tgross35 opened this issue Jul 9, 2024 · 1 comment
Assignees

Comments

@tgross35
Copy link

tgross35 commented Jul 9, 2024

define half @trunckfhf(fp128 %a) unnamed_addr {
start:
  %_0 = fptrunc fp128 %a to half
  ret half %_0
}

Output on powerpc64-unknown-linux-gnu:

trunckfhf:                              # @trunckfhf
        .quad   .Lfunc_begin0
        .quad   .TOC.@tocbase
        .quad   0
.Lfunc_begin0:
        mflr 0
        stdu 1, -112(1)
        std 0, 128(1)
        bl __trunctfhf2
        nop
        clrldi  3, 3, 48
        bl __gnu_h2f_ieee
        nop
        addi 1, 1, 112
        ld 0, 16(1)
        mtlr 0
        blr
        .long   0
        .quad   0

Note that this emits __trunctfhf2. According to https://gcc.gnu.org/wiki/Ieee128PowerPC (second table in section 2.2), tf is for whatever long double is in C, which on PPC is usually IBM double double, but kf is always for IEEE binary128. So it seems like this should instead emit a symbol named __trunckfhf2.

This would be consistent with other fptrunc operations for fp128, which lower to kf symbols (__trunckfsf2, __trunckfdf2).

There is more discussion at this thread #92866. Neither GCC nor LLVM provide this symbol yet in libgcc/compiler-rt, but I don't think that should block correcting the symbol name.

Tested at compiler explorer using 19.0.0git. Link: https://llvm.godbolt.org/z/7MosczYcr

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 9, 2024

@llvm/issue-subscribers-backend-powerpc

Author: Trevor Gross (tgross35)

```llvm define half @trunckfhf(fp128 %a) unnamed_addr { start: %_0 = fptrunc fp128 %a to half ret half %_0 } ```

Output on powerpc64-unknown-linux-gnu:

trunckfhf:                              # @<!-- -->trunckfhf
        .quad   .Lfunc_begin0
        .quad   .TOC.@<!-- -->tocbase
        .quad   0
.Lfunc_begin0:
        mflr 0
        stdu 1, -112(1)
        std 0, 128(1)
        bl __trunctfhf2
        nop
        clrldi  3, 3, 48
        bl __gnu_h2f_ieee
        nop
        addi 1, 1, 112
        ld 0, 16(1)
        mtlr 0
        blr
        .long   0
        .quad   0

Note that this emits __trunctfhf2. According to https://gcc.gnu.org/wiki/Ieee128PowerPC (second table in section 2.2), tf is for whatever long double is in C, which on PPC is usually IBM double double, but kf is always for IEEE binary128. So it seems like this should instead emit a symbol named __trunckfhf2.

This would be consistent with other fptrunc operations for fp128, which lower to kf symbols (__trunckfsf2, __trunckfdf2).

There is more discussion at this thread #92866. Neither GCC nor LLVM provide this symbol yet in libgcc/compiler-rt, but I don't think that should block correcting the symbol name.

Tested at compiler explorer using 19.0.0git. Link: https://llvm.godbolt.org/z/7MosczYcr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants