Bug 35657 - Alignments of DFP types aren't consistent
Summary: Alignments of DFP types aren't consistent
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.3.0
: P1 blocker
Target Milestone: 4.3.1
Assignee: H.J. Lu
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ABI
Depends on:
Blocks:
 
Reported: 2008-03-21 17:42 UTC by H.J. Lu
Modified: 2008-05-08 19:12 UTC (History)
1 user (show)

See Also:
Host:
Target: i686-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-05-01 14:14:56


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2008-03-21 17:42:51 UTC
ix86_function_arg_boundary returns PARM_BOUNDARY for TDmode
for ia32. Should it return 128bit? The psABI isn't clear on
it. I think it should be aligned at 128bit.
Comment 1 Uroš Bizjak 2008-03-21 20:53:45 UTC
(In reply to comment #0)
> ix86_function_arg_boundary returns PARM_BOUNDARY for TDmode
> for ia32. Should it return 128bit? The psABI isn't clear on
> it. I think it should be aligned at 128bit.

Yes, because it is moved to/from XMM registers. Currently, this exact problem is handled by a specialization code in ix86_expand_vector_move that forces unaligned instructions for TDmode memory moves via ix86_expand_vector_move_misalign.

Please note that we have to be compatible with SSE x86 and non-SSE x86 code, so TDmode can't be passed in XMM registers on x86_32 targets.

I'd wait for psABI to clear situation w.r.t to alignment first.
Comment 2 H.J. Lu 2008-03-22 00:27:08 UTC
It is a question how TDmode should be aligned on stack when
passing to a function. I will ask it on the ia32 psABI group.
Comment 3 H.J. Lu 2008-03-25 00:42:12 UTC
This patch will align DFP to its natural boundary.

Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c      (revision 1917)
+++ gcc/config/i386/i386.c      (working copy)
@@ -4609,7 +4609,8 @@ ix86_function_arg_boundary (enum machine
     align = GET_MODE_ALIGNMENT (mode);
   if (align < PARM_BOUNDARY)
     align = PARM_BOUNDARY;
-  if (!TARGET_64BIT)
+  /* Decimal floating point is aligned to its natural boundary.  */
+  if (!TARGET_64BIT && !VALID_DFP_MODE_P (mode))
     {
       /* i386 ABI defines all arguments to be 4 byte aligned.  We have to
         make an exception for SSE modes since these require 128bit
Comment 4 hjl@gcc.gnu.org 2008-03-27 18:53:07 UTC
Subject: Bug 35657

Author: hjl
Date: Thu Mar 27 18:52:18 2008
New Revision: 133649

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133649
Log:
2008-03-27  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/35657
	* config/i386/i386.c (ix86_function_arg_boundary): Align
	decimal floating point to its natural boundary.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c

Comment 5 hjl@gcc.gnu.org 2008-03-27 18:56:20 UTC
Subject: Bug 35657

Author: hjl
Date: Thu Mar 27 18:55:36 2008
New Revision: 133651

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133651
Log:
2008-03-27  H.J. Lu  <hongjiu.lu@intel.com>

	Backport from mainline:
	2008-03-27  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/35657
	* config/i386/i386.c (ix86_function_arg_boundary): Align
	decimal floating point to its natural boundary.

Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/config/i386/i386.c

Comment 6 H.J. Lu 2008-03-27 19:05:07 UTC
Fixed.
Comment 7 Uroš Bizjak 2008-04-29 18:06:08 UTC
The alignment of TDmode is not yet decided, see http://groups.google.com/group/ia32-abi/browse_thread/thread/fc6db344b62dea76

Reopened as P1 bug, blocking 4.3.1 release, as per suggestion in http://gcc.gnu.org/ml/gcc-patches/2008-04/msg02135.html
Comment 8 H.J. Lu 2008-04-29 18:44:04 UTC
On IA32, all 8 byte types should be aligned at 4 byte and 16byte types
should be aligned at 16 byte. The only discrepancy is alignment of
8byte DFP type, _Decimal64. Gcc aligns it at 8 byte. But we should
treat its alignment like double.
Comment 9 H.J. Lu 2008-04-30 20:55:36 UTC
It turns out that __m64 is aligned to 4 byte in the outgoing
parameter block and 8 byte elsewhere. We want _Decimal64 to be
consistent with __m64, not double/long long.
Comment 10 H.J. Lu 2008-05-01 14:14:55 UTC
A patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2008-05/msg00035.html
Comment 11 H.J. Lu 2008-05-05 22:49:34 UTC
An updated patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2008-05/msg00271.html
Comment 12 hjl@gcc.gnu.org 2008-05-06 15:41:52 UTC
Subject: Bug 35657

Author: hjl
Date: Tue May  6 15:41:08 2008
New Revision: 134987

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134987
Log:
2008-05-06  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/35657
	* config/i386/i386.c (contains_128bit_aligned_vector_p): Renamed
	to ...
	(contains_aligned_value_p): This.  Handle _Decimal128.
	(ix86_function_arg_boundary): Only align _Decimal128 to its
	natural boundary and handle it properly.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c

Comment 13 hjl@gcc.gnu.org 2008-05-08 19:12:06 UTC
Subject: Bug 35657

Author: hjl
Date: Thu May  8 19:11:23 2008
New Revision: 135089

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=135089
Log:
2008-05-08  H.J. Lu  <hongjiu.lu@intel.com>

	Backport from mainline:
	2008-05-06  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/35657
	* config/i386/i386.c (contains_128bit_aligned_vector_p): Renamed
	to ...
	(contains_aligned_value_p): This.  Handle _Decimal128.
	(ix86_function_arg_boundary): Only align _Decimal128 to its
	natural boundary and handle it properly.

Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/config/i386/i386.c

Comment 14 H.J. Lu 2008-05-08 19:12:52 UTC
Fixed.