[PATCH] Fix common-code ppcf128 component access on little-endian

Ulrich Weigand Ulrich.Weigand at de.ibm.com
Fri Jun 20 10:40:00 PDT 2014



Hello,

the PowerPC 128-bit long double data type (ppcf128 in LLVM) is in fact a
pair of two doubles, where one is considered the "high" or more-significant
part, and the other is considered the "low" or less-significant part.  When
a ppcf128 value is stored in memory or a register pair, the high part
always comes first, i.e. at the lower memory address or in the
lower-numbered register, and the low part always comes second.  This is
true both on big-endian and little-endian PowerPC systems.  (Similar to how
with a complex number, the real part always comes first and the imaginary
part second, no matter the byte order of the system.)

This is currently implemented incorrectly for little-endian systems in
LLVM.   There are three issues I've noticed in my tests on ppc64le:

- When printing an immediate ppcf128 constant to assembler output, current
code in emitGlobalConstantFP does indeed correctly emit the high part first
on big-endian systems, but emits the *low* part first on little-endian
systems.
- When lowering a ppcf128 type to a pair of f64 types in SelectionDAG
(which is used e.g. when generating code to load an argument into a
register pair), low and high part are inverted on little-endian systems.
- In a related issue, because lowering ppcf128 into a pair of f64 must
operate differently from lowering an int128 into a pair of i64, bitcasts
between ppcf128 and int128 must not be optimized away by the DAG combiner.

The attached patch fixes these issues; this makes all native testing on
powerpc64le pass (including full test-suite and bootstrap), when my
not-yet-published ELFv2 patches are also applied.

I'd appreciate a review; is this OK to commit?

(See attached file: diff-llvm-le-ppcf128)


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand | Phone: +49-7031/16-3727
  STSM, GNU/Linux compilers and toolchain
  IBM Deutschland Research & Development GmbH
  Vorsitzende des Aufsichtsrats: Martina Koederitz | Geschäftsführung: Dirk
Wittkopp
  Sitz der Gesellschaft: Böblingen | Registergericht: Amtsgericht
Stuttgart, HRB 243294
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff-llvm-le-ppcf128
Type: application/octet-stream
Size: 5105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140620/92a24c9a/attachment.obj>


More information about the llvm-commits mailing list