This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[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
- From: "uwe at netbsd dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Dec 2003 01:49:31 -0000
- 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
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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