public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/30159]  New: [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled on sh-elf and mips-elf
@ 2006-12-12  0:15 kkojima at gcc dot gnu dot org
  2006-12-12 13:01 ` [Bug tree-optimization/30159] [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled kkojima at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: kkojima at gcc dot gnu dot org @ 2006-12-12  0:15 UTC (permalink / raw)
  To: gcc-bugs

On sh-elf, the function foo in 20010422-1.c

unsigned int foo(unsigned int x)
{
  if (x < 5)
    x = 4;
  else
    x = 8;
  return x;
}

is compiled to

foo:
        mov.l   r14,@-r15
        mov     r15,r14
        mov     #4,r1
        cmp/hi  r1,r1
        bf/s    .L6
        mov     #4,r0
        mov     #8,r0
.L6:
        mov     r14,r15
        mov.l   @r15+,r14
        rts
        nop

with -O1.  Thus the first parameter register r4 is ignored.
For mips-elf, foo is assembled to

foo:
        .frame  $sp,0,$31               # vars= 0, regs= 0/0, args= 0, gp= 0
        .mask   0x00000000,0
        .fmask  0x00000000,0
        .set    noreorder
        .set    nomacro

        sltu    $2,$2,5
        beq     $2,$0,$L2
        nop
        ...

with -O1 where $4 should be register for x.
It started after the patch

r119711 | amacleod | 2006-12-11 06:25:40 +0900 (Mon, 11 Dec 2006) | 103 lines

and the first tree dump which differs before and after this patch
is .099t.optimized:

[r119710 .099t.optimized]
;; Function foo (foo)

Analyzing Edge Insertions.
foo (x)
{
  unsigned int x.24;

<bb 2>:
  if (x <= 4) goto <L5>; else goto <L4>;

<L5>:;
  x.24 = 4;
  goto <bb 4> (<L2>);

<L4>:;
  x.24 = 8;

<L2>:;
  return x.24;

}

[r119711 .099t.optimized]
;; Function foo (foo)

Analyzing Edge Insertions.
foo (x)
{
  unsigned int x.24;

<bb 2>:
  if (x.24 <= 4) goto <L5>; else goto <L4>;

<L5>:;
  x = 4;
  goto <bb 4> (<L2>);

<L4>:;
  x = 8;

<L2>:;
  return x;

}


-- 
           Summary: [4.3 Regression] gcc.c-torture/execute/20010422-1.c is
                    miscompiled on sh-elf and mips-elf
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kkojima at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: sh-elf, mips-elf


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


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

* [Bug tree-optimization/30159] [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled
  2006-12-12  0:15 [Bug tree-optimization/30159] New: [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled on sh-elf and mips-elf kkojima at gcc dot gnu dot org
@ 2006-12-12 13:01 ` kkojima at gcc dot gnu dot org
  2006-12-12 13:52 ` dnovillo at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: kkojima at gcc dot gnu dot org @ 2006-12-12 13:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from kkojima at gcc dot gnu dot org  2006-12-12 13:01 -------
A slightly different test case

unsigned int foo(unsigned int x)
{
  if (x < 5)
    x = 4;
  else
    x = 8;
  return x;
}

int main(void)
{
  if (foo (4) != 4)
    abort ();
  if (foo (8) != 8)
    abort ();
  exit (0);
}

aborts on i686-pc-linux-gnu with -O1 and -O2.


-- 

kkojima at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 GCC target triplet|sh-elf, mips-elf            |sh-elf, mips-elf, i686-pc-
                   |                            |linux-gnu
            Summary|[4.3 Regression] gcc.c-     |[4.3 Regression] gcc.c-
                   |torture/execute/20010422-1.c|torture/execute/20010422-1.c
                   |is miscompiled on sh-elf and|is miscompiled
                   |mips-elf                    |


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


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

* [Bug tree-optimization/30159] [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled
  2006-12-12  0:15 [Bug tree-optimization/30159] New: [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled on sh-elf and mips-elf kkojima at gcc dot gnu dot org
  2006-12-12 13:01 ` [Bug tree-optimization/30159] [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled kkojima at gcc dot gnu dot org
@ 2006-12-12 13:52 ` dnovillo at gcc dot gnu dot org
  2006-12-12 14:11 ` amacleod at redhat dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dnovillo at gcc dot gnu dot org @ 2006-12-12 13:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from dnovillo at gcc dot gnu dot org  2006-12-12 13:51 -------

Adding Andrew to CC list.  Seems related to out-of-ssa changes.


-- 

dnovillo at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amacleod at redhat dot com


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


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

* [Bug tree-optimization/30159] [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled
  2006-12-12  0:15 [Bug tree-optimization/30159] New: [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled on sh-elf and mips-elf kkojima at gcc dot gnu dot org
  2006-12-12 13:01 ` [Bug tree-optimization/30159] [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled kkojima at gcc dot gnu dot org
  2006-12-12 13:52 ` dnovillo at gcc dot gnu dot org
@ 2006-12-12 14:11 ` amacleod at redhat dot com
  2006-12-12 15:50 ` amacleod at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: amacleod at redhat dot com @ 2006-12-12 14:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from amacleod at redhat dot com  2006-12-12 14:11 -------
Analyzing Edge Insertions.
foo (x)
{
  unsigned int x.24;

<bb 2>:
  if (x.24 <= 4) goto <L5>; else goto <L4>;

Yeah, this is clearly wrong. It looks like the coalescer somehow neglected to
coalesce the parameter to the first use in bb2, so it ended up getting the
wrong 'x' in the comparison. The x and x.24's should all be reversed.


-- 

amacleod at redhat dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |amacleod at redhat dot com
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-12-12 14:11:13
               date|                            |


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


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

* [Bug tree-optimization/30159] [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled
  2006-12-12  0:15 [Bug tree-optimization/30159] New: [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled on sh-elf and mips-elf kkojima at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-12-12 14:11 ` amacleod at redhat dot com
@ 2006-12-12 15:50 ` amacleod at gcc dot gnu dot org
  2006-12-12 19:54 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: amacleod at gcc dot gnu dot org @ 2006-12-12 15:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from amacleod at redhat dot com  2006-12-12 15:50 -------
Subject: Bug 30159

Author: amacleod
Date: Tue Dec 12 15:50:06 2006
New Revision: 119792

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

2006-12-12  Andrew Macleod  <amacleod@redhat.com>

        PR tree-optimization/30159
        * tree-ssa-coalesce.c (coalesce_ssa_name): Process single ssa_name 
        functions in case a default_def coalesce is required.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-ssa-coalesce.c


-- 


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


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

* [Bug tree-optimization/30159] [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled
  2006-12-12  0:15 [Bug tree-optimization/30159] New: [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled on sh-elf and mips-elf kkojima at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-12-12 15:50 ` amacleod at gcc dot gnu dot org
@ 2006-12-12 19:54 ` pinskia at gcc dot gnu dot org
  2006-12-12 23:20 ` kkojima at gcc dot gnu dot org
  2006-12-13  5:42 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-12-12 19:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2006-12-12 19:53 -------
*** Bug 30178 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |danglin at gcc dot gnu dot
                   |                            |org


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


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

* [Bug tree-optimization/30159] [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled
  2006-12-12  0:15 [Bug tree-optimization/30159] New: [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled on sh-elf and mips-elf kkojima at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-12-12 19:54 ` pinskia at gcc dot gnu dot org
@ 2006-12-12 23:20 ` kkojima at gcc dot gnu dot org
  2006-12-13  5:42 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: kkojima at gcc dot gnu dot org @ 2006-12-12 23:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from kkojima at gcc dot gnu dot org  2006-12-12 23:20 -------
The patch fixes the problem also on sh-elf and mips-elf.  Thanks!
BTW, I'm a bit surprised that current testcases didn't catch it on x86.
How about to add a new testcase?


-- 


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


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

* [Bug tree-optimization/30159] [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled
  2006-12-12  0:15 [Bug tree-optimization/30159] New: [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled on sh-elf and mips-elf kkojima at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2006-12-12 23:20 ` kkojima at gcc dot gnu dot org
@ 2006-12-13  5:42 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-12-13  5:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2006-12-13 05:42 -------
Fixed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


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

end of thread, other threads:[~2006-12-13  5:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-12  0:15 [Bug tree-optimization/30159] New: [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled on sh-elf and mips-elf kkojima at gcc dot gnu dot org
2006-12-12 13:01 ` [Bug tree-optimization/30159] [4.3 Regression] gcc.c-torture/execute/20010422-1.c is miscompiled kkojima at gcc dot gnu dot org
2006-12-12 13:52 ` dnovillo at gcc dot gnu dot org
2006-12-12 14:11 ` amacleod at redhat dot com
2006-12-12 15:50 ` amacleod at gcc dot gnu dot org
2006-12-12 19:54 ` pinskia at gcc dot gnu dot org
2006-12-12 23:20 ` kkojima at gcc dot gnu dot org
2006-12-13  5:42 ` pinskia 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).