Bug 10519 - optimization based on SSA "-O2 -fssa" uses wrong register
Summary: optimization based on SSA "-O2 -fssa" uses wrong register
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: wrong-code
Depends on:
Reported: 2003-04-28 12:26 UTC by heinrich.brand
Modified: 2003-07-11 16:52 UTC (History)
1 user (show)

See Also:
Host: sparc-sun-solaris2.8
Target: sparc-sun-solaris2.8
Build: sparc-sun-solaris2.8
Known to work:
Known to fail:
Last reconfirmed: 2003-06-04 19:51:50


Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2003-04-28 08:38:13 UTC
From: Andrew Pinski <pinskia@physics.uc.edu>
To: Heinrich.Brand@fujitsu-siemens.com
Cc: gcc-gnats@gcc.gnu.org, Erwin.Unruh@fujitsu-siemens.com
Subject: Re: optimization/10519: optimization based on SSA "-O2 -fssa" uses wrong register
Date: Mon, 28 Apr 2003 08:38:13 -0400

 -fssa is not ready for production use, from  
   Users should not specify this option, since it is not yet ready for  
 production use.
 Since -fssa is going away in favor of something different, do not use  
 this flag.
 Andrew Pinski
Comment 1 heinrich.brand 2003-04-28 12:26:00 UTC
The test below compiles and executes successfully
with -O2 but fails with -O2 -fssa. The  disassembled code
differs in one register in one place. A function should add
2 input registers and return the sum but in the "-O2 -fssa" case
only one register is used in the add instruction.

(Source code is in How-To-Repeat.) 

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

           0:  81 c3 e0 08         jmp          %o7 + 8
           4:  90 02 00 09         add          %o0, %o1, %o0

-O2 -fssa :

           0:  81 c3 e0 08         jmp          %o7 + 8
-------------------- wrong register in add: ------------------------ 
           4:  90 02 00 08         add          %o0, %o0, %o0

both cases (only offsets differ):

           8:  9d e3 bf 90         save         %sp, -112, %sp
           c:  92 10 20 04         mov          4, %o1
          10:  40 00 00 00         call         0x10
          14:  90 10 20 03         mov          3, %o0
          18:  80 a2 20 07         cmp          %o0, 7
End of the disassembled code.

Release: gcc version 3.3 20030407 (prerelease)

SunOS 5.8 sparc

The the test with output FAILED can be repeated by:
Compile following source code 
with gcc 3.3 20030407 -O2 -fssa
execute resulting program 

int printf(const char *format, ...);
int f(int a, int b){
        int *xa,*xb;
        return *xa+*(xb);
int main(){
  if( f(3,4)==7 )
  return 0;
Comment 2 heinrich.brand 2003-04-28 12:26:00 UTC
Do not use "-O2 -fssa" .
Comment 3 Dara Hazeghi 2003-06-01 23:09:54 UTC

I can confirm this problem on i686-linux. gcc 3.2.3 is fine, but both 3.3 branch and mainline 
(20030527) fail... I agree with Andrew that -fssa is probably going away in its current form, but 
still, this is broken, so I think we should probably just make this a low-priority bug, at least until -
fssa finally is removed. Or should this perhaps be mapped to the RESOLVED: WONTFIX category?

Comment 4 Dara Hazeghi 2003-06-04 19:51:50 UTC
Confirmed (at least for now)...
Comment 5 Andrew Pinski 2003-07-11 16:52:22 UTC
-fssa is being removed from the mainline <http://gcc.gnu.org/ml/gcc/2003-07/
msg00070.html> so we will not fix this. The workaround is not to use -fssa at all.