public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/40906]  New: Wrong code generated for push of long double
@ 2009-07-29 17:04 mikulas at artax dot karlin dot mff dot cuni dot cz
  2009-07-29 17:07 ` [Bug rtl-optimization/40906] " mikulas at artax dot karlin dot mff dot cuni dot cz
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: mikulas at artax dot karlin dot mff dot cuni dot cz @ 2009-07-29 17:04 UTC (permalink / raw)
  To: gcc-bugs

Hi. Try this program:

#include <stdlib.h>

void f(long double a)
{
        if (a != 1.0) abort();
}

int g(long double b)
{
        f(b);
        return 0;
}

int main(void)
{
        g(1.0);
        return 0;
}

Compile it with "-O2 -mpush-args -mno-accumulate-outgoing-args
-fomit-frame-pointer -fno-inline"

In gcc 4.3.2 it works, in gcc-4.4.1 it aborts. If you add -m128bit-long-double,
both gcc 4.3 and 4.4 fail. The reason is that push of long double in the
function "g" is badly generated --- it is pushing value that is already on the
stack and while it is pushing it, the stack pointer changes. Gcc tries to
compensate for it, but the code is buggy and it ends up pushing wrong words.


-- 
           Summary: Wrong code generated for push of long double
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mikulas at artax dot karlin dot mff dot cuni dot cz
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug rtl-optimization/40906] Wrong code generated for push of long double
  2009-07-29 17:04 [Bug rtl-optimization/40906] New: Wrong code generated for push of long double mikulas at artax dot karlin dot mff dot cuni dot cz
@ 2009-07-29 17:07 ` mikulas at artax dot karlin dot mff dot cuni dot cz
  2009-07-29 18:15 ` [Bug target/40906] " rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mikulas at artax dot karlin dot mff dot cuni dot cz @ 2009-07-29 17:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from mikulas at artax dot karlin dot mff dot cuni dot cz  2009-07-29 17:07 -------
Created an attachment (id=18270)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18270&action=view)
A patch for the bug

A patch for the problem.

1. reverse the direction of "change_address" loop. That fixes 4.3->4.4
regression for 96-bit long double.

2. in case of 128-bit long double, the value "4" is subtracted from the stack
pointer before the copying starts. We need to compensate for it by adding "4"
to the source address if the source address in on the stack.

Problem "2" should be backported to gcc-4.3 and earlier versions.


-- 


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


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

* [Bug target/40906] Wrong code generated for push of long double
  2009-07-29 17:04 [Bug rtl-optimization/40906] New: Wrong code generated for push of long double mikulas at artax dot karlin dot mff dot cuni dot cz
  2009-07-29 17:07 ` [Bug rtl-optimization/40906] " mikulas at artax dot karlin dot mff dot cuni dot cz
@ 2009-07-29 18:15 ` rguenth at gcc dot gnu dot org
  2009-08-05 14:42 ` uros at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-07-29 18:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2009-07-29 18:15 -------
patches should be sent to gcc-patches with a proper changelog entry and a note
on how you tested the patch.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ABI, wrong-code


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


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

* [Bug target/40906] Wrong code generated for push of long double
  2009-07-29 17:04 [Bug rtl-optimization/40906] New: Wrong code generated for push of long double mikulas at artax dot karlin dot mff dot cuni dot cz
  2009-07-29 17:07 ` [Bug rtl-optimization/40906] " mikulas at artax dot karlin dot mff dot cuni dot cz
  2009-07-29 18:15 ` [Bug target/40906] " rguenth at gcc dot gnu dot org
@ 2009-08-05 14:42 ` uros at gcc dot gnu dot org
  2009-08-05 18:05 ` uros at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: uros at gcc dot gnu dot org @ 2009-08-05 14:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from uros at gcc dot gnu dot org  2009-08-05 14:42 -------
Subject: Bug 40906

Author: uros
Date: Wed Aug  5 14:41:54 2009
New Revision: 150486

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150486
Log:
        PR target/40906
        * config/i386/i386.c (ix86_split_long_move): Fix push of multi-part
        source operand.

testsuite/ChangeLog:

        PR target/40906
        * gcc.target/i386/pr40906-1.c: New test.
        * gcc.target/i386/pr40906-2.c: Ditto.
        * gcc.target/i386/pr40906-3.c: Ditto.


Added:
    trunk/gcc/testsuite/gcc.target/i386/pr40906-1.c
    trunk/gcc/testsuite/gcc.target/i386/pr40906-2.c
    trunk/gcc/testsuite/gcc.target/i386/pr40906-3.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug target/40906] Wrong code generated for push of long double
  2009-07-29 17:04 [Bug rtl-optimization/40906] New: Wrong code generated for push of long double mikulas at artax dot karlin dot mff dot cuni dot cz
                   ` (2 preceding siblings ...)
  2009-08-05 14:42 ` uros at gcc dot gnu dot org
@ 2009-08-05 18:05 ` uros at gcc dot gnu dot org
  2009-08-05 21:17 ` uros at gcc dot gnu dot org
  2009-08-05 21:19 ` ubizjak at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: uros at gcc dot gnu dot org @ 2009-08-05 18:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from uros at gcc dot gnu dot org  2009-08-05 18:05 -------
Subject: Bug 40906

Author: uros
Date: Wed Aug  5 18:04:42 2009
New Revision: 150497

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150497
Log:
        PR target/40906
        * config/i386/i386.c (ix86_split_long_move): Fix push of multi-part
        source operand.

testsuite/ChangeLog:

        PR target/40906
        * gcc.target/i386/pr40906-1.c: New test.
        * gcc.target/i386/pr40906-2.c: Ditto.
        * gcc.target/i386/pr40906-3.c: Ditto.


Added:
    branches/gcc-4_4-branch/gcc/testsuite/gcc.target/i386/pr40906-1.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.target/i386/pr40906-2.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.target/i386/pr40906-3.c
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/config/i386/i386.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug target/40906] Wrong code generated for push of long double
  2009-07-29 17:04 [Bug rtl-optimization/40906] New: Wrong code generated for push of long double mikulas at artax dot karlin dot mff dot cuni dot cz
                   ` (3 preceding siblings ...)
  2009-08-05 18:05 ` uros at gcc dot gnu dot org
@ 2009-08-05 21:17 ` uros at gcc dot gnu dot org
  2009-08-05 21:19 ` ubizjak at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: uros at gcc dot gnu dot org @ 2009-08-05 21:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from uros at gcc dot gnu dot org  2009-08-05 21:17 -------
Subject: Bug 40906

Author: uros
Date: Wed Aug  5 21:16:52 2009
New Revision: 150501

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150501
Log:
        PR target/40906
        * config/i386/i386.c (ix86_split_long_move): Fix push of multi-part
        source operand.

testsuite/ChangeLog:

        PR target/40906
        * gcc.target/i386/pr40906-1.c: New test.
        * gcc.target/i386/pr40906-2.c: Ditto.
        * gcc.target/i386/pr40906-3.c: Ditto.


Added:
    branches/gcc-4_3-branch/gcc/testsuite/gcc.target/i386/pr40906-1.c
    branches/gcc-4_3-branch/gcc/testsuite/gcc.target/i386/pr40906-2.c
    branches/gcc-4_3-branch/gcc/testsuite/gcc.target/i386/pr40906-3.c
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/config/i386/i386.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug target/40906] Wrong code generated for push of long double
  2009-07-29 17:04 [Bug rtl-optimization/40906] New: Wrong code generated for push of long double mikulas at artax dot karlin dot mff dot cuni dot cz
                   ` (4 preceding siblings ...)
  2009-08-05 21:17 ` uros at gcc dot gnu dot org
@ 2009-08-05 21:19 ` ubizjak at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: ubizjak at gmail dot com @ 2009-08-05 21:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from ubizjak at gmail dot com  2009-08-05 21:19 -------
Fixed.


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
      Known to fail|                            |4.4.1 4.3.4
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.5


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


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

end of thread, other threads:[~2009-08-05 21:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-29 17:04 [Bug rtl-optimization/40906] New: Wrong code generated for push of long double mikulas at artax dot karlin dot mff dot cuni dot cz
2009-07-29 17:07 ` [Bug rtl-optimization/40906] " mikulas at artax dot karlin dot mff dot cuni dot cz
2009-07-29 18:15 ` [Bug target/40906] " rguenth at gcc dot gnu dot org
2009-08-05 14:42 ` uros at gcc dot gnu dot org
2009-08-05 18:05 ` uros at gcc dot gnu dot org
2009-08-05 21:17 ` uros at gcc dot gnu dot org
2009-08-05 21:19 ` ubizjak 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).