From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32265 invoked by alias); 28 Apr 2003 12:26:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 32244 invoked by uid 71); 28 Apr 2003 12:26:00 -0000 Resent-Date: 28 Apr 2003 12:26:00 -0000 Resent-Message-ID: <20030428122600.32243.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, Erwin.Unruh@fujitsu-siemens.com Resent-Reply-To: gcc-gnats@gcc.gnu.org, Heinrich.Brand@fujitsu-siemens.com Received: (qmail 29738 invoked by uid 48); 28 Apr 2003 12:17:36 -0000 Message-Id: <20030428121736.29737.qmail@sources.redhat.com> Date: Mon, 28 Apr 2003 12:26:00 -0000 From: Heinrich.Brand@fujitsu-siemens.com Reply-To: Heinrich.Brand@fujitsu-siemens.com To: gcc-gnats@gcc.gnu.org Cc: Erwin.Unruh@fujitsu-siemens.com X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) X-GNATS-Notify: Erwin.Unruh@fujitsu-siemens.com Subject: optimization/10519: optimization based on SSA "-O2 -fssa" uses wrong register X-SW-Source: 2003-04/txt/msg01239.txt.bz2 List-Id: >Number: 10519 >Category: optimization >Synopsis: optimization based on SSA "-O2 -fssa" uses wrong register >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Mon Apr 28 12:26:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: Heinrich Brand >Release: 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 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 : fy() 0: 81 c3 e0 08 jmp %o7 + 8 4: 90 02 00 09 add %o0, %o1, %o0 ******************************************************************* -O2 -fssa : fy() 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): main() 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. >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, ...); int f(int a, int b){ int *xa,*xb; xa=&a;xb=&b; return *xa+*(xb); } int main(){ if( f(3,4)==7 ) printf("SUCCESSFUL\n"); else printf("FAILED\n"); return 0; } >Fix: Do not use "-O2 -fssa" . >Release-Note: >Audit-Trail: >Unformatted: