public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/25196]  New: i386: wrong arguments passed
@ 2005-12-01  6:05 markus at oberhumer dot com
  2005-12-01  6:06 ` [Bug target/25196] " markus at oberhumer dot com
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: markus at oberhumer dot com @ 2005-12-01  6:05 UTC (permalink / raw)
  To: gcc-bugs

I really had a hard time tracking this down from a large program: gcc 4.0.2 on
i386-linux sometimes passes wrong arguments.

Please try the attached source file on i386 with "gcc-4.0.2 -march=i386 -O3
-fomit-frame-pointer".

When looking at the disassembly of f2() it seems that %edi is incorrectly used
twice:

  5e:   89 f8                   mov    %edi,%eax   !!!!!
  60:   ff 74 24 24             pushl  0x24(%esp)
  64:   55                      push   %ebp
  65:   89 f9                   mov    %edi,%ecx   !!!!!
  67:   89 da                   mov    %ebx,%edx
  69:   e8 92 ff ff ff          call   0 <f1>

This wrong-code bug is probably a 3.2, 3.3 and 3.4 regression.

~Markus


-- 
           Summary: i386: wrong arguments passed
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: markus at oberhumer dot com
  GCC host triplet: i386-pc-linux


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


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

* [Bug target/25196] i386: wrong arguments passed
  2005-12-01  6:05 [Bug target/25196] New: i386: wrong arguments passed markus at oberhumer dot com
@ 2005-12-01  6:06 ` markus at oberhumer dot com
  2005-12-01  7:02 ` [Bug target/25196] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: markus at oberhumer dot com @ 2005-12-01  6:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from markus at oberhumer dot com  2005-12-01 06:06 -------
Created an attachment (id=10373)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10373&action=view)
wrong_args.c

Please try "gcc-4.0.2 -march=i386 -O3 -fomit-frame-pointer wrong_args.c"


-- 


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


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

* [Bug target/25196] [4.0/4.1 Regression] i386: wrong arguments passed
  2005-12-01  6:05 [Bug target/25196] New: i386: wrong arguments passed markus at oberhumer dot com
  2005-12-01  6:06 ` [Bug target/25196] " markus at oberhumer dot com
@ 2005-12-01  7:02 ` pinskia at gcc dot gnu dot org
  2005-12-19 18:50 ` mmitchel at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-12-01  7:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2005-12-01 07:02 -------
This works at least on the mainline (but I don't know if this is a latent bug
or not).


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical
           Keywords|                            |wrong-code
      Known to work|                            |3.4.0 4.2.0
            Summary|i386: wrong arguments passed|[4.0/4.1 Regression] i386:
                   |                            |wrong arguments passed
   Target Milestone|---                         |4.0.3


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


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

* [Bug target/25196] [4.0/4.1 Regression] i386: wrong arguments passed
  2005-12-01  6:05 [Bug target/25196] New: i386: wrong arguments passed markus at oberhumer dot com
  2005-12-01  6:06 ` [Bug target/25196] " markus at oberhumer dot com
  2005-12-01  7:02 ` [Bug target/25196] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
@ 2005-12-19 18:50 ` mmitchel at gcc dot gnu dot org
  2005-12-20  9:17 ` [Bug rtl-optimization/25196] " belyshev at depni dot sinp dot msu dot ru
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-12-19 18:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from mmitchel at gcc dot gnu dot org  2005-12-19 18:50 -------
Serious wrong code problem: P1.


-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1


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


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

* [Bug rtl-optimization/25196] [4.0/4.1 Regression] i386: wrong arguments passed
  2005-12-01  6:05 [Bug target/25196] New: i386: wrong arguments passed markus at oberhumer dot com
                   ` (2 preceding siblings ...)
  2005-12-19 18:50 ` mmitchel at gcc dot gnu dot org
@ 2005-12-20  9:17 ` belyshev at depni dot sinp dot msu dot ru
  2005-12-20 10:17 ` steven at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: belyshev at depni dot sinp dot msu dot ru @ 2005-12-20  9:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from belyshev at depni dot sinp dot msu dot ru  2005-12-20 09:17 -------
// short testcase, compile with "-m32 -march=i386 -O3 -fomit-frame-pointer"

extern void abort (void);

static int j;

static void __attribute__((noinline))
f1 (int a, int b, int c, int d, int e)
{
  j = a;
}

int __attribute__((noinline))
f2 (int a, int b, int c, int d, int e)
{
  if ((b & 0x1111) != 1)
    f1 (a, b, c, d, e);
  return 0;
}

int main (void)
{
  f2 (123, 0, 0, 0, 0);
  if (j != 123)
    abort ();
  return 0;
}

---

Note that this bug disappears with -fno-gcse-after-reload, here is difference
in generated assembly between -fno-gcse-after-reload (---) and
-fgcse-after-reload (+++):

$ diff -U 5 1.s 2.s                                                             
--- 1.s 2005-12-20 12:10:44.000000000 +0300
+++ 2.s 2005-12-20 12:10:41.000000000 +0300
@@ -14,13 +14,13 @@
        movl    12(%esp), %ecx
        movl    %edx, %eax
        andl    $4369, %eax
        decl    %eax
        je      .L4
+       movl    %ecx, %eax
        pushl   20(%esp)
        pushl   20(%esp)
-       movl    12(%esp), %eax
        call    f1
        popl    %eax
        popl    %edx
 .L4:
        xorl    %eax, %eax
$ 

So this bug looks very much like bug 23453.


-- 

belyshev at depni dot sinp dot msu dot ru changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|target                      |rtl-optimization
     Ever Confirmed|0                           |1
   GCC host triplet|i386-pc-linux               |
 GCC target triplet|                            |i386-pc-linux
   Last reconfirmed|0000-00-00 00:00:00         |2005-12-20 09:17:31
               date|                            |


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


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

* [Bug rtl-optimization/25196] [4.0/4.1 Regression] i386: wrong arguments passed
  2005-12-01  6:05 [Bug target/25196] New: i386: wrong arguments passed markus at oberhumer dot com
                   ` (3 preceding siblings ...)
  2005-12-20  9:17 ` [Bug rtl-optimization/25196] " belyshev at depni dot sinp dot msu dot ru
@ 2005-12-20 10:17 ` steven at gcc dot gnu dot org
  2005-12-20 10:18 ` steven at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-12-20 10:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from steven at gcc dot gnu dot org  2005-12-20 10:17 -------
Re. comment #4: but this new PR has a much simpler test case :-)


-- 


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


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

* [Bug rtl-optimization/25196] [4.0/4.1 Regression] i386: wrong arguments passed
  2005-12-01  6:05 [Bug target/25196] New: i386: wrong arguments passed markus at oberhumer dot com
                   ` (4 preceding siblings ...)
  2005-12-20 10:17 ` steven at gcc dot gnu dot org
@ 2005-12-20 10:18 ` steven at gcc dot gnu dot org
  2005-12-20 10:59 ` belyshev at depni dot sinp dot msu dot ru
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-12-20 10:18 UTC (permalink / raw)
  To: gcc-bugs



-- 

steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |steven at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-12-20 09:17:31         |2005-12-20 10:18:24
               date|                            |


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


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

* [Bug rtl-optimization/25196] [4.0/4.1 Regression] i386: wrong arguments passed
  2005-12-01  6:05 [Bug target/25196] New: i386: wrong arguments passed markus at oberhumer dot com
                   ` (5 preceding siblings ...)
  2005-12-20 10:18 ` steven at gcc dot gnu dot org
@ 2005-12-20 10:59 ` belyshev at depni dot sinp dot msu dot ru
  2005-12-20 14:59 ` steven at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: belyshev at depni dot sinp dot msu dot ru @ 2005-12-20 10:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from belyshev at depni dot sinp dot msu dot ru  2005-12-20 10:59 -------
*** Bug 23453 has been marked as a duplicate of this bug. ***


-- 

belyshev at depni dot sinp dot msu dot ru changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |debian-gcc at lists dot
                   |                            |debian dot org


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


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

* [Bug rtl-optimization/25196] [4.0/4.1 Regression] i386: wrong arguments passed
  2005-12-01  6:05 [Bug target/25196] New: i386: wrong arguments passed markus at oberhumer dot com
                   ` (6 preceding siblings ...)
  2005-12-20 10:59 ` belyshev at depni dot sinp dot msu dot ru
@ 2005-12-20 14:59 ` steven at gcc dot gnu dot org
  2005-12-20 15:58 ` steven at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-12-20 14:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from steven at gcc dot gnu dot org  2005-12-20 14:59 -------
Does not fail with trunk or the head of the gcc 4.1 branch.  But it does fail
with gcc 4.0.2.  I'm going to try it with the head of the gcc 4.0 branch now.


-- 


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


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

* [Bug rtl-optimization/25196] [4.0/4.1 Regression] i386: wrong arguments passed
  2005-12-01  6:05 [Bug target/25196] New: i386: wrong arguments passed markus at oberhumer dot com
                   ` (7 preceding siblings ...)
  2005-12-20 14:59 ` steven at gcc dot gnu dot org
@ 2005-12-20 15:58 ` steven at gcc dot gnu dot org
  2005-12-21 15:46 ` [Bug rtl-optimization/25196] [4.0 " steven at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-12-20 15:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from steven at gcc dot gnu dot org  2005-12-20 15:58 -------
Gross.  According to a comment in postreload.c:move2add_note_store(), we can
have pushes without REG_INC notes:
  /* Some targets do argument pushes without adding REG_INC notes.  */

So we need to go look for those {pre,post}{decrements,increments} ourselves. 
With this patch, we just do what postreload.c does.


Index: postreload-gcse.c
===================================================================
--- postreload-gcse.c   (revision 108853)
+++ postreload-gcse.c   (working copy)
@@ -676,6 +676,17 @@ record_last_set_info (rtx dest, rtx sett
           /* Ignore pushes, they clobber nothing.  */
           && ! push_operand (dest, GET_MODE (dest)))
     record_last_mem_set_info (last_set_insn);
+
+  /* ??? Some targets do argument pushes without adding REG_INC notes.
+     See e.g. PR25196, where a pushsi2 on i386 doesn't have REG_INC
+     notes.  */
+  if (MEM_P (dest))
+    {
+      dest = XEXP (dest, 0);
+      if (GET_CODE (dest) == PRE_INC || GET_CODE (dest) == POST_INC
+         || GET_CODE (dest) == PRE_DEC || GET_CODE (dest) == POST_DEC)
+       record_last_reg_set_info (last_set_insn, REGNO (XEXP (dest, 0)));
+    }
 }


-- 


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


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

* [Bug rtl-optimization/25196] [4.0 Regression] i386: wrong arguments passed
  2005-12-01  6:05 [Bug target/25196] New: i386: wrong arguments passed markus at oberhumer dot com
                   ` (8 preceding siblings ...)
  2005-12-20 15:58 ` steven at gcc dot gnu dot org
@ 2005-12-21 15:46 ` steven at gcc dot gnu dot org
  2006-01-27 18:03 ` markus at oberhumer dot com
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-12-21 15:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from steven at gcc dot gnu dot org  2005-12-21 15:46 -------
Fixed on the trunk and on the GCC 4.1 branch.
See http://gcc.gnu.org/ml/gcc-cvs/2005-12/msg01177.html and
http://gcc.gnu.org/ml/gcc-cvs/2005-12/msg01178.html (I used the wrong bug
number in the commit >:-/)

Will ask for permission for the 4.0 branch in a few days.


-- 

steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.0/4.1 Regression] i386:  |[4.0 Regression] i386: wrong
                   |wrong arguments passed      |arguments passed


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


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

* [Bug rtl-optimization/25196] [4.0 Regression] i386: wrong arguments passed
  2005-12-01  6:05 [Bug target/25196] New: i386: wrong arguments passed markus at oberhumer dot com
                   ` (9 preceding siblings ...)
  2005-12-21 15:46 ` [Bug rtl-optimization/25196] [4.0 " steven at gcc dot gnu dot org
@ 2006-01-27 18:03 ` markus at oberhumer dot com
  2006-02-27 20:21 ` mmitchel at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: markus at oberhumer dot com @ 2006-01-27 18:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from markus at oberhumer dot com  2006-01-27 18:03 -------
What is the status of this bug for gcc 4.0.3 ?

According to the thread at
http://gcc.gnu.org/ml/gcc-patches/2006-01/msg00542.html it seems it has been
approved a while ago.


-- 


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


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

* [Bug rtl-optimization/25196] [4.0 Regression] i386: wrong arguments passed
  2005-12-01  6:05 [Bug target/25196] New: i386: wrong arguments passed markus at oberhumer dot com
                   ` (10 preceding siblings ...)
  2006-01-27 18:03 ` markus at oberhumer dot com
@ 2006-02-27 20:21 ` mmitchel at gcc dot gnu dot org
  2006-02-27 21:13 ` steven at gcc dot gnu dot org
  2006-02-27 21:34 ` steven at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-02-27 20:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from mmitchel at gcc dot gnu dot org  2006-02-27 20:17 -------
Steven, would you please apply this patch ASAP?

Thanks,

-- Mark


-- 


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


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

* [Bug rtl-optimization/25196] [4.0 Regression] i386: wrong arguments passed
  2005-12-01  6:05 [Bug target/25196] New: i386: wrong arguments passed markus at oberhumer dot com
                   ` (11 preceding siblings ...)
  2006-02-27 20:21 ` mmitchel at gcc dot gnu dot org
@ 2006-02-27 21:13 ` steven at gcc dot gnu dot org
  2006-02-27 21:34 ` steven at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: steven at gcc dot gnu dot org @ 2006-02-27 21:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from steven at gcc dot gnu dot org  2006-02-27 21:12 -------
Subject: Bug 25196

Author: steven
Date: Mon Feb 27 21:12:54 2006
New Revision: 111490

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=111490
Log:
        Backport from mainline and the GCC 4.1 branch:
        PR rtl-optimization/25196
        * postreload-gcse.c (record_last_set_info): Notice stack pointer
        changes in push insns without REG_INC notes.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/gcc.dg/pr25196.c
Modified:
    branches/gcc-4_0-branch/gcc/ChangeLog
    branches/gcc-4_0-branch/gcc/postreload-gcse.c


-- 


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


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

* [Bug rtl-optimization/25196] [4.0 Regression] i386: wrong arguments passed
  2005-12-01  6:05 [Bug target/25196] New: i386: wrong arguments passed markus at oberhumer dot com
                   ` (12 preceding siblings ...)
  2006-02-27 21:13 ` steven at gcc dot gnu dot org
@ 2006-02-27 21:34 ` steven at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: steven at gcc dot gnu dot org @ 2006-02-27 21:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from steven at gcc dot gnu dot org  2006-02-27 21:13 -------
'tis done.


-- 

steven at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2006-02-27 21:13 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-01  6:05 [Bug target/25196] New: i386: wrong arguments passed markus at oberhumer dot com
2005-12-01  6:06 ` [Bug target/25196] " markus at oberhumer dot com
2005-12-01  7:02 ` [Bug target/25196] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
2005-12-19 18:50 ` mmitchel at gcc dot gnu dot org
2005-12-20  9:17 ` [Bug rtl-optimization/25196] " belyshev at depni dot sinp dot msu dot ru
2005-12-20 10:17 ` steven at gcc dot gnu dot org
2005-12-20 10:18 ` steven at gcc dot gnu dot org
2005-12-20 10:59 ` belyshev at depni dot sinp dot msu dot ru
2005-12-20 14:59 ` steven at gcc dot gnu dot org
2005-12-20 15:58 ` steven at gcc dot gnu dot org
2005-12-21 15:46 ` [Bug rtl-optimization/25196] [4.0 " steven at gcc dot gnu dot org
2006-01-27 18:03 ` markus at oberhumer dot com
2006-02-27 20:21 ` mmitchel at gcc dot gnu dot org
2006-02-27 21:13 ` steven at gcc dot gnu dot org
2006-02-27 21:34 ` steven at gcc dot gnu dot org

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).