From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25012 invoked by alias); 1 Dec 2003 01:49:35 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 24947 invoked by uid 48); 1 Dec 2003 01:49:31 -0000 Date: Mon, 01 Dec 2003 01:49:00 -0000 From: "uwe at netbsd dot org" To: gcc-bugs@gcc.gnu.org Message-ID: <20031201014925.13250.uwe@netbsd.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug optimization/13250] New: [SH] Gcc code for rotation clobbers the register, but gcc continues to use the register as if it was not clobbered X-Bugzilla-Reason: CC X-SW-Source: 2003-12/txt/msg00023.txt.bz2 List-Id: gcc-3.3.2 and 3.4 miscompile sha256 digest code for SuperH, minimized test case attached. The sha256 transformation computes a sum that has (amongst others) the following subexpressions: + (... ^ ((((e)) >> (25)) | (((e)) << (32 - (25))))) + (((e) & (f)) ^ ((~(e)) & (g))) Code generated with -O is: swap.w r4,r1 ! r4 contains "e" shll8 r4 ! "e" in r4 gets clobbered shlr8 r1 or r4,r1 rotr r1 ! rotate "e" 25 bits xor r1,r2 mov.l @(8,r14),r1 add r1,r2 ! enclosing sum mov r4,r3 ! <-- gcc thinks r4 still has the value of "e" !!! and r13,r3 ! e & f not r4,r1 ! ~e and r6,r1 ! ~e & g xor r1,r3 ! (e & f) ^ (~e & g) add r3,r2 ! add into the sum -- Summary: [SH] Gcc code for rotation clobbers the register, but gcc continues to use the register as if it was not clobbered Product: gcc Version: 3.4 Status: UNCONFIRMED Severity: normal Priority: P2 Component: optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: uwe at netbsd dot org CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i386-unknown-freebsd4.8 GCC host triplet: i386-unknown-freebsd4.8 GCC target triplet: shle--netbsdelf http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13250