public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/9962: Scheduling bug on i386
@ 2003-03-05  7:16 ksakamot
  0 siblings, 0 replies; 2+ messages in thread
From: ksakamot @ 2003-03-05  7:16 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9962
>Category:       optimization
>Synopsis:       Scheduling bug on i386
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 05 07:16:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     ksakamot@lsi.melco.co.jp
>Release:        3.2.2
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
When the following source is compiled with "-O2 -fschedule-insns -fno-schedule-insns2", the scheduling is incorrect.

> gcc -S -O2 -fschedule-insns -fno-schedule-insns2 sched-bug.c
> cat sched-bug.s 
        .file   "sched-bug.c"
        .text
        .p2align 4,,15
.globl func
        .type   func,@function
func:
        pushl   %ebp
        movl    %esp, %ebp
        movzwl  12(%ebp), %edx
        movl    8(%ebp), %eax
        movw    %dx, (%eax)
        movl    $0, (%eax)
        popl    %ebp
        ret
.Lfe1:
        .size   func,.Lfe1-func
        .ident  "GCC: (GNU) 3.2.2"

"movl $0, (%eax)" is generated from "rr-code = code" and "movw %dx, (%eax)" is generated from "((unsigned long *)rr)[0] = 0;".
So "movw %dx, (%eax)" should be located after "movl $0, (%eax)".
>How-To-Repeat:
typedef struct r {
  unsigned short code;
  int a;
} ST;

void func( ST *rr, unsigned short code )
{
  ((unsigned long *)rr)[0] = 0;
  rr->code = code;
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

* Re: optimization/9962: Scheduling bug on i386
@ 2003-03-05  7:35 ebotcazou
  0 siblings, 0 replies; 2+ messages in thread
From: ebotcazou @ 2003-03-05  7:35 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, ksakamot, nobody

Synopsis: Scheduling bug on i386

State-Changed-From-To: open->closed
State-Changed-By: ebotcazou
State-Changed-When: Wed Mar  5 07:35:56 2003
State-Changed-Why:
    Not a bug. Your code breaks the ISO C aliasing rules. GCC
    automatically turns on -fstrict-aliasing at -O2 so you need
    to fix your code or compile it with -fno-strict-aliasing.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9962


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

end of thread, other threads:[~2003-03-05  7:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-05  7:16 optimization/9962: Scheduling bug on i386 ksakamot
2003-03-05  7:35 ebotcazou

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