public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Heinrich.Brand@fujitsu-siemens.com
To: gcc-gnats@gcc.gnu.org
Cc: Erwin.Unruh@fujitsu-siemens.com
Subject: optimization/10494: gcc 3.3 20030407 optimization based on SSA "-O2 -fssa" removes needed code
Date: Fri, 25 Apr 2003 10:26:00 -0000	[thread overview]
Message-ID: <20030425102231.28715.qmail@sources.redhat.com> (raw)


>Number:         10494
>Category:       optimization
>Synopsis:       gcc 3.3 20030407 optimization based on SSA "-O2 -fssa" removes needed code
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 25 10:26:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Heinrich Brand
>Release:        gcc version 3.3 20030407 (prerelease)
>Organization:
>Environment:
SunOS 5.8 sparc
>Description:
The test below compiles and executes successfully
with -O2 but fails with -O2 -fssa. The difference 
of the disassembled code shows that with -O2 -fssa 
a needed instruction is missing so a function does 
not return a value (but should return a value).
(Source code is in How-To-Repeat.) 

*******************************************************************
The dissembled code of both cases ("-O2" OK  and "-O2 -fssa" wrong) :
*******************************************************************
-O2 :

f0()
           0:  81 c3 e0 08         jmp          %o7 + 8
           4:  c0 22 00 00         st           %g0, [%o0]
f1()
           8:  9d e3 bf 88         save         %sp, -120, %sp
           c:  c0 27 bf ec         st           %g0, [%fp - 20]
          10:  7f ff ff fc         call         f0
          14:  90 07 bf ec         add          %fp, -20, %o0
          18:  f0 07 bf ec         ld           [%fp - 20], %i0
          1c:  01 00 00 00         nop          
          20:  81 c7 e0 08         ret          
          24:  81 e8 00 00         restore      
*******************************************************************
-O2 -fssa :

f0()
           0:  81 c3 e0 08         jmp          %o7 + 8
           4:  c0 22 00 00         st           %g0, [%o0]
f1()
           8:  9d e3 bf 88         save         %sp, -120, %sp
           c:  7f ff ff fd         call         f0
          10:  90 07 bf ec         add          %fp, -20, %o0
---------------- %i0 is not set but %o0 is used in main ! ------          
          14:  01 00 00 00         nop          
          18:  81 c7 e0 08         ret          
          1c:  81 e8 00 00         restore      
*******************************************************************
both cases (only offsets differ):

--------------- %o0 is in main not set otherwise ------------------
main()
          20:  9d e3 bf 90         save         %sp, -112, %sp
          24:  40 00 00 00         call         0x24
          28:  01 00 00 00         nop          
          2c:  80 a2 20 00         cmp          %o0, 0
          30:  32 80 00 05         bne,a   0x44
...
*******************************************************************
End of the disassembled code of the first test.


*******************************************************************
Another test:
*******************************************************************

If in the source code "f0(&k);" is replaced by "*(&k) = 0;"
The following code is generated:

*******************************************************************
The dissembled code of both cases ("-O2" OK  and "-O2 -fssa" wrong) :
*******************************************************************
-O2:

f1()
           8:  81 c3 e0 08         jmp          %o7 + 8
           c:  90 10 20 00         clr          %o0
*******************************************************************
-O2 -fssa:

f1()
           8:  01 00 00 00         nop     
           c:  81 c3 e0 08         jmp          %o7 + 8
----------------- %o0 is not set but used in main ---------------------
          10:  01 00 00 00         nop     
*******************************************************************
both cases  (only offsets differ):

--------------- %o0 is in main not set otherwise ------------------

 main()
          14:  9d e3 bf 90         save         %sp, -112, %sp
          18:  40 00 00 00         call         0x18
          1c:  01 00 00 00         nop     
          20:  80 a2 20 00         cmp          %o0, 0
          24:  32 80 00 05         bne,a   0x38
...
*******************************************************************
End of the disassembled code of the second test.
 
>How-To-Repeat:
The the test with output FAILED can be repeated by:
Compile following source code 
with gcc 3.3 20030407  -O2 -fssa
and
execute resulting program 

int printf(const char *format, ...);
static  void f0 (long *y) { *y = 0; return; }
int f1 () {
        long k=0;
        f0(&k);
        return k;
}
int main () {
        if (f1() == 0) printf("SUCCESSFUL\n"); else printf("FAILED\n");
        return 0;
}
>Fix:
Do not use "-O2 -fssa" . 
>Release-Note:
>Audit-Trail:
>Unformatted:


                 reply	other threads:[~2003-04-25 10:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030425102231.28715.qmail@sources.redhat.com \
    --to=heinrich.brand@fujitsu-siemens.com \
    --cc=Erwin.Unruh@fujitsu-siemens.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).