[all-commits] [llvm/llvm-project] 1e60b8: [PowerPC][SDAG] fix bitcast on ppc_f128 swapping t...

Folkert de Vries via All-commits all-commits at lists.llvm.org
Sat Oct 3 05:32:06 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1e60b852a9d7f73ffed3540e9ea84aefde1b80ab
      https://github.com/llvm/llvm-project/commit/1e60b852a9d7f73ffed3540e9ea84aefde1b80ab
  Author: Folkert de Vries <folkert at folkertdev.nl>
  Date:   2026-10-03 (Sat, 03 Oct 2026)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    A llvm/test/CodeGen/PowerPC/ppcf128-constant-bitcast.ll

  Log Message:
  -----------
  [PowerPC][SDAG] fix bitcast on ppc_f128 swapping the two halves (#208969)

fixes https://github.com/llvm/llvm-project/issues/44482

This is a long-standing issue
https://github.com/llvm/llvm-project/issues/44482, you can also see the
discrepancy in this small C program compiled with clang and GCC
https://godbolt.org/z/KK1q1EozM.

The representation of ppc_fp128 is endian-agnostic in that its
high-order double is stored at the lower address.

For example, 27.0 is represented in memory as `[0x403b000000000000,
0x0000000000000000]`. Bitcasting these 128 bits as an i128 on
little-endian means the upper 64 bits are `0x0000000000000000`, the
lower are `0x403b000000000000`.

But on big-endian the interpretation of the bytes is flipped, the upper
bits are now `0x403b000000000000` while the lower are in
`0x0000000000000000`.

The `bitcastToAPInt` does not account for endianness, so I've added a
manual rotation to put the right double in the expected place. This is
kind of fragile still, but at least fixes current issues.

---------

Co-authored-by: Amy Kwan <amy.kwan1 at ibm.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list