public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/35771]  New: Call expander ignores type alignment
@ 2008-03-30 22:11 hjl dot tools at gmail dot com
  2008-03-30 23:59 ` [Bug middle-end/35771] " hjl dot tools at gmail dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-03-30 22:11 UTC (permalink / raw)
  To: gcc-bugs

Call expander ignores type alignment. But caller honors type alignment.
It usually isn't a problem until the argument is passed via stack. We
have a mismatch between caller and callee:

bash-3.2$ cat x.c
typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));

__m128  __attribute__((noinline))
iszero (__m128 x)
{
  return x;
}

typedef  __m128 __attribute__((aligned(1))) unaligned;

__m128  __attribute__((noinline))
foo (__m128 a1, __m128 a2, __m128 a3, __m128 a4,
     __m128 a5, __m128 a6, __m128 a7, __m128 a8,
     int b1, int b2, int b3, int b4, int b5, int b6, int b7, unaligned y)
{
  return iszero (y);
}

int
main (void)
{
  unaligned x;
  __m128 y, x0 = { 0 };
  x = x0; 
  y = foo (x0, x0, x0, x0, x0, x0, x0, x0, 1, 2, 3, 4, 5, 6, 7, x);
  return __builtin_memcmp (&y, &x0, sizeof (y));
}
bash-3.2$ make
/export/build/gnu/gcc/build-x86_64-linux/stage1-gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/stage1-gcc/ -O -g    -c -o x.o x.c
/export/build/gnu/gcc/build-x86_64-linux/stage1-gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/stage1-gcc/   x.o   -o x
./x
make: *** [all] Segmentation fault
bash-3.2$ gdb x
GNU gdb Red Hat Linux (6.6-45.fc8rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu"...
Using host libthread_db library "/lib64/libthread_db.so.1".
(gdb) r
Starting program: /export/home/hjl/bugs/gcc/35767/x 

Program received signal SIGSEGV, Segmentation fault.
foo (a1={0, 0, 0, 0}, a2={0, 0, 0, 0}, a3={0, 0, 0, 0}, a4={0, 0, 0, 0}, a5=
      {0, 0, 0, 0}, a6={0, 0, 0, 0}, a7={0, 0, 0, 0}, a8={0, 0, 0, 0}, b1=1, 
    b2=2, b3=3, b4=4, b5=5, b6=6, b7=7, y={5.87934249e-39, 0, 0, 0}) at x.c:16
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^
                                          Should be {0, 0, 0, 0}
16        return iszero (y);
Missing separate debuginfos, use: debuginfo-install glibc.x86_64
(gdb) f 1
#1  0x00000000004004c3 in main () at x.c:25
25        y = foo (x0, x0, x0, x0, x0, x0, x0, x0, 1, 2, 3, 4, 5, 6, 7, x);
(gdb) p x
No symbol "x" in current context.
(gdb) p x0
$1 = {0, 0, 0, 0}
(gdb) 

The segfault is PR 35767.


-- 
           Summary: Call expander ignores type alignment
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hjl dot tools at gmail dot com
GCC target triplet: x86_64-unknown-linux-gnu
 BugsThisDependsOn: 35767


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35771


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/35771] Call expander ignores type alignment
  2008-03-30 22:11 [Bug middle-end/35771] New: Call expander ignores type alignment hjl dot tools at gmail dot com
@ 2008-03-30 23:59 ` hjl dot tools at gmail dot com
  2008-03-31  2:05 ` hjl dot tools at gmail dot com
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-03-30 23:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from hjl dot tools at gmail dot com  2008-03-30 23:58 -------
The problem is __m128 shoulbn't the canonical type for unaligned.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35771


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/35771] Call expander ignores type alignment
  2008-03-30 22:11 [Bug middle-end/35771] New: Call expander ignores type alignment hjl dot tools at gmail dot com
  2008-03-30 23:59 ` [Bug middle-end/35771] " hjl dot tools at gmail dot com
@ 2008-03-31  2:05 ` hjl dot tools at gmail dot com
  2008-03-31  4:47 ` hjl dot tools at gmail dot com
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-03-31  2:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from hjl dot tools at gmail dot com  2008-03-31 02:04 -------
useless_type_conversion_p returns true for

(gdb) call debug_tree (outer_type)
 <vector_type 0x2aaaaac11240 unaligned
    type <real_type 0x2aaaaab0a6c0 float asm_written SF
        size <integer_cst 0x2aaaaaaeba80 constant invariant 32>
        unit size <integer_cst 0x2aaaaaaeb6f0 constant invariant 4>
        align 32 symtab -1430183552 alias set -1 canonical type 0x2aaaaab0a6c0
precision 32
        pointer_to_this <pointer_type 0x2aaaaab0a900>>
    sizes-gimplified V4SF
    size <integer_cst 0x2aaaaaaebde0 type <integer_type 0x2aaaaaafb0c0
bit_size_type> constant invariant 128>
    unit size <integer_cst 0x2aaaaaaebe10 type <integer_type 0x2aaaaaafb000
long unsigned int> constant invariant 16>
    user align 8 symtab -1430183264 alias set -1 canonical type 0x2aaaaac11240
    attributes <tree_list 0x2aaaaac108a0
        purpose <identifier_node 0x2aaaaabe0f60 __may_alias__>> nunits 4>
(gdb) call debug_tree (inner_type)
 <vector_type 0x2aaaaac110c0 __m128
    type <real_type 0x2aaaaab0a6c0 float asm_written SF
        size <integer_cst 0x2aaaaaaeba80 constant invariant 32>
        unit size <integer_cst 0x2aaaaaaeb6f0 constant invariant 4>
        align 32 symtab -1430183552 alias set -1 canonical type 0x2aaaaab0a6c0
precision 32
        pointer_to_this <pointer_type 0x2aaaaab0a900>>
    sizes-gimplified V4SF
    size <integer_cst 0x2aaaaaaebde0 type <integer_type 0x2aaaaaafb0c0
bit_size_type> constant invariant 128>
    unit size <integer_cst 0x2aaaaaaebe10 type <integer_type 0x2aaaaaafb000
long unsigned int> constant invariant 16>
    align 128 symtab -1430183936 alias set -1 canonical type 0x2aaaaabab900
    attributes <tree_list 0x2aaaaac108a0
        purpose <identifier_node 0x2aaaaabe0f60 __may_alias__>> nunits 4
    pointer_to_this <pointer_type 0x2aaaaac116c0>>

It isn't correct.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35771


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/35771] Call expander ignores type alignment
  2008-03-30 22:11 [Bug middle-end/35771] New: Call expander ignores type alignment hjl dot tools at gmail dot com
  2008-03-30 23:59 ` [Bug middle-end/35771] " hjl dot tools at gmail dot com
  2008-03-31  2:05 ` hjl dot tools at gmail dot com
@ 2008-03-31  4:47 ` hjl dot tools at gmail dot com
  2008-03-31 13:50 ` hjl dot tools at gmail dot com
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-03-31  4:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from hjl dot tools at gmail dot com  2008-03-31 04:46 -------


*** This bug has been marked as a duplicate of 35767 ***


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35771


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/35771] Call expander ignores type alignment
  2008-03-30 22:11 [Bug middle-end/35771] New: Call expander ignores type alignment hjl dot tools at gmail dot com
                   ` (2 preceding siblings ...)
  2008-03-31  4:47 ` hjl dot tools at gmail dot com
@ 2008-03-31 13:50 ` hjl dot tools at gmail dot com
  2008-05-27 20:20 ` hjl at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-03-31 13:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from hjl dot tools at gmail dot com  2008-03-31 13:49 -------
Reopen it since it is a different bug.


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|DUPLICATE                   |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35771


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/35771] Call expander ignores type alignment
  2008-03-30 22:11 [Bug middle-end/35771] New: Call expander ignores type alignment hjl dot tools at gmail dot com
                   ` (3 preceding siblings ...)
  2008-03-31 13:50 ` hjl dot tools at gmail dot com
@ 2008-05-27 20:20 ` hjl at gcc dot gnu dot org
  2008-05-27 20:22 ` hjl dot tools at gmail dot com
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: hjl at gcc dot gnu dot org @ 2008-05-27 20:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from hjl at gcc dot gnu dot org  2008-05-27 20:19 -------
Subject: Bug 35771

Author: hjl
Date: Tue May 27 20:18:33 2008
New Revision: 136054

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=136054
Log:
gcc/

2008-05-27  H.J. Lu  <hongjiu.lu@intel.com>

        PR target/35767
        PR target/35771
        * config/i386/i386.c (ix86_function_arg_boundary): Use
        alignment of canonical type.
        (ix86_expand_vector_move): Check unaligned memory access for
        all SSE modes.

gcc/testsuite/

2008-05-27  H.J. Lu  <hongjiu.lu@intel.com>

        PR target/35767
        PR target/35771
        * gcc.target/i386/pr35767-1.c: New.
        * gcc.target/i386/pr35767-1d.c: Likewise.
        * gcc.target/i386/pr35767-1i.c: Likewise.
        * gcc.target/i386/pr35767-2.c: Likewise.
        * gcc.target/i386/pr35767-2d.c: Likewise.
        * gcc.target/i386/pr35767-2i.c: Likewise.
        * gcc.target/i386/pr35767-3.c: Likewise.
        * gcc.target/i386/pr35767-4.c: Likewise.
        * gcc.target/i386/pr35767-5.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.target/i386/pr35767-1.c
    trunk/gcc/testsuite/gcc.target/i386/pr35767-1d.c
    trunk/gcc/testsuite/gcc.target/i386/pr35767-1i.c
    trunk/gcc/testsuite/gcc.target/i386/pr35767-2.c
    trunk/gcc/testsuite/gcc.target/i386/pr35767-2d.c
    trunk/gcc/testsuite/gcc.target/i386/pr35767-2i.c
    trunk/gcc/testsuite/gcc.target/i386/pr35767-3.c
    trunk/gcc/testsuite/gcc.target/i386/pr35767-4.c
    trunk/gcc/testsuite/gcc.target/i386/pr35767-5.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35771


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/35771] Call expander ignores type alignment
  2008-03-30 22:11 [Bug middle-end/35771] New: Call expander ignores type alignment hjl dot tools at gmail dot com
                   ` (4 preceding siblings ...)
  2008-05-27 20:20 ` hjl at gcc dot gnu dot org
@ 2008-05-27 20:22 ` hjl dot tools at gmail dot com
  2008-05-28 22:57 ` hjl dot tools at gmail dot com
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-05-27 20:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from hjl dot tools at gmail dot com  2008-05-27 20:22 -------
Fixed.


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.4.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35771


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/35771] Call expander ignores type alignment
  2008-03-30 22:11 [Bug middle-end/35771] New: Call expander ignores type alignment hjl dot tools at gmail dot com
                   ` (5 preceding siblings ...)
  2008-05-27 20:22 ` hjl dot tools at gmail dot com
@ 2008-05-28 22:57 ` hjl dot tools at gmail dot com
  2008-05-28 23:26 ` hjl dot tools at gmail dot com
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-05-28 22:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from hjl dot tools at gmail dot com  2008-05-28 22:56 -------
It isn't fixed by revision 136054. Those new tests will fail at -O0
since revision 136054 doesn't address the real issu here.


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|FIXED                       |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35771


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/35771] Call expander ignores type alignment
  2008-03-30 22:11 [Bug middle-end/35771] New: Call expander ignores type alignment hjl dot tools at gmail dot com
                   ` (6 preceding siblings ...)
  2008-05-28 22:57 ` hjl dot tools at gmail dot com
@ 2008-05-28 23:26 ` hjl dot tools at gmail dot com
  2008-05-29  4:41 ` hjl dot tools at gmail dot com
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-05-28 23:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from hjl dot tools at gmail dot com  2008-05-28 23:25 -------
Created an attachment (id=15696)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15696&action=view)
A testcase patch

They will fail with

FAIL: gcc.dg/torture/pr35771-1.c  -O0  execution test
FAIL: gcc.dg/torture/pr35771-2.c  -O0  execution test

on Linux/ia32.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35771


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/35771] Call expander ignores type alignment
  2008-03-30 22:11 [Bug middle-end/35771] New: Call expander ignores type alignment hjl dot tools at gmail dot com
                   ` (7 preceding siblings ...)
  2008-05-28 23:26 ` hjl dot tools at gmail dot com
@ 2008-05-29  4:41 ` hjl dot tools at gmail dot com
  2008-05-29 12:36 ` hjl at gcc dot gnu dot org
  2008-05-29 16:08 ` hjl dot tools at gmail dot com
  10 siblings, 0 replies; 12+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-05-29  4:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from hjl dot tools at gmail dot com  2008-05-29 04:40 -------
A patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2008-05/msg01906.html


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Joey dot ye at intel dot
                   |                            |com, xuepeng dot guo at
                   |                            |intel dot com
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2008-
                   |                            |05/msg01906.html


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35771


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/35771] Call expander ignores type alignment
  2008-03-30 22:11 [Bug middle-end/35771] New: Call expander ignores type alignment hjl dot tools at gmail dot com
                   ` (8 preceding siblings ...)
  2008-05-29  4:41 ` hjl dot tools at gmail dot com
@ 2008-05-29 12:36 ` hjl at gcc dot gnu dot org
  2008-05-29 16:08 ` hjl dot tools at gmail dot com
  10 siblings, 0 replies; 12+ messages in thread
From: hjl at gcc dot gnu dot org @ 2008-05-29 12:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from hjl at gcc dot gnu dot org  2008-05-29 12:35 -------
Subject: Bug 35771

Author: hjl
Date: Thu May 29 12:35:04 2008
New Revision: 136159

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=136159
Log:
gcc/

2008-05-29  H.J. Lu  <hongjiu.lu@intel.com>

        PR target/35771
        * config/i386/i386.c (ix86_function_arg_boundary): Convert to
        canonical type if needed.

gcc/testsuite/

2008-05-29  H.J. Lu  <hongjiu.lu@intel.com>

        PR target/35771
        * gcc.dg/torture/pr35771.h: New.
        * gcc.dg/torture/pr35771-1.c: Likewise.
        * gcc.dg/torture/pr35771-2.c: Likewise.
        * gcc.dg/torture/pr35771-3.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr35771-1.c
    trunk/gcc/testsuite/gcc.dg/torture/pr35771-2.c
    trunk/gcc/testsuite/gcc.dg/torture/pr35771-3.c
    trunk/gcc/testsuite/gcc.dg/torture/pr35771.h
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35771


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/35771] Call expander ignores type alignment
  2008-03-30 22:11 [Bug middle-end/35771] New: Call expander ignores type alignment hjl dot tools at gmail dot com
                   ` (9 preceding siblings ...)
  2008-05-29 12:36 ` hjl at gcc dot gnu dot org
@ 2008-05-29 16:08 ` hjl dot tools at gmail dot com
  10 siblings, 0 replies; 12+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-05-29 16:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from hjl dot tools at gmail dot com  2008-05-29 16:08 -------
Fixed.


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35771


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-05-29 16:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-30 22:11 [Bug middle-end/35771] New: Call expander ignores type alignment hjl dot tools at gmail dot com
2008-03-30 23:59 ` [Bug middle-end/35771] " hjl dot tools at gmail dot com
2008-03-31  2:05 ` hjl dot tools at gmail dot com
2008-03-31  4:47 ` hjl dot tools at gmail dot com
2008-03-31 13:50 ` hjl dot tools at gmail dot com
2008-05-27 20:20 ` hjl at gcc dot gnu dot org
2008-05-27 20:22 ` hjl dot tools at gmail dot com
2008-05-28 22:57 ` hjl dot tools at gmail dot com
2008-05-28 23:26 ` hjl dot tools at gmail dot com
2008-05-29  4:41 ` hjl dot tools at gmail dot com
2008-05-29 12:36 ` hjl at gcc dot gnu dot org
2008-05-29 16:08 ` hjl dot tools at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).