First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 13250
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Kazumoto Kojima <kkojima@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Valeriy E. Ushakov <uwe@netbsd.org>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
sha2.i test case that demonstrates the problem text/plain 2003-12-01 01:50 1.17 KB Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 13250 depends on: Show dependency tree
Show dependency graph
Bug 13250 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2004-01-21 04:03 Opened: 2003-12-01 01:49
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

------- Comment #1 From Valeriy E. Ushakov 2003-12-01 01:50 -------
Created an attachment (id=5247) [edit]
test case that demonstrates the problem

------- Comment #2 From Dara Hazeghi 2004-01-21 04:03 -------
Confirmed on both branches (and mainline). Any sh expert want to take a look?

------- Comment #3 From Kazumoto Kojima 2004-05-27 03:19 -------
This looks an SH target specific problem when generating rtl for rotation
like (e << 8) | (e >> 24).  It seems the patch below for sh.md fixes this.
I'll propose it to gcc-patch list after bootstrap and regtest.

--- ORIG/gcc/gcc/config/sh/sh.md	2004-05-14 10:08:34.000000000 +0900
+++ LOCAL/gcc/gcc/config/sh/sh.md	2004-05-27 08:32:37.000000000 +0900
@@ -2194,7 +2194,7 @@
 	parts[0] = gen_reg_rtx (SImode);
 	parts[1] = gen_reg_rtx (SImode);
 	emit_insn (gen_rotlsi3_16 (parts[2-choice], operands[1]));
-	parts[choice-1] = operands[1];
+	emit_move_insn (parts[choice-1], operands[1]);
 	emit_insn (gen_ashlsi3 (parts[0], parts[0], GEN_INT (8)));
 	emit_insn (gen_lshrsi3 (parts[1], parts[1], GEN_INT (8)));
 	emit_insn (gen_iorsi3 (operands[0], parts[0], parts[1]));


------- Comment #4 From Valeriy E. Ushakov 2004-05-27 21:03 -------
Subject: Re:  [SH] Gcc code for rotation clobbers the register, but gcc
continues to use the register as if it was not clobbered

With this fix applied the test case program passes its tests.

-uwe

------- Comment #5 From Kazumoto Kojima 2004-05-28 04:24 -------
FYI, I've proposed the above patch:
http://gcc.gnu.org/ml/gcc-patches/2004-05/msg01782.html

------- Comment #6 From CVS Commits 2004-05-28 05:47 -------
Subject: Bug 13250

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	kkojima@gcc.gnu.org	2004-05-28 05:47:37

Modified files:
	gcc            : ChangeLog 
	gcc/config/sh  : sh.md 

Log message:
	PR target/13250
	* config/sh/sh.md (rotlsi3): Use emit_move_insn.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.3767&r2=2.3768
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sh/sh.md.diff?cvsroot=gcc&r1=1.171&r2=1.172


------- Comment #7 From CVS Commits 2004-06-01 00:07 -------
Subject: Bug 13250

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	kkojima@gcc.gnu.org	2004-06-01 00:07:52

Modified files:
	gcc            : ChangeLog 
	gcc/config/sh  : sh.md 

Log message:
	PR target/13250
	Backport from mainline:
	
	2004-05-28  Kaz Kojima  <kkojima@gcc.gnu.org>
	* config/sh/sh.md (rotlsi3): Use emit_move_insn.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.461&r2=2.2326.2.462
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sh/sh.md.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.165.4.2&r2=1.165.4.3


------- Comment #8 From Andrew Pinski 2004-06-01 00:13 -------
Fixed.

------- Comment #9 From CVS Commits 2004-07-26 00:48 -------
Subject: Bug 13250

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	kkojima@gcc.gnu.org	2004-07-26 00:48:24

Modified files:
	gcc            : ChangeLog 
	gcc/config/sh  : sh.md t-linux 
	libstdc++-v3   : ChangeLog configure 
Added files:
	gcc/config/sh  : libgcc-std.ver 

Log message:
	PR target/13250
	Backport from mainline:
	* config/sh/sh.md (rotlsi3): Use emit_move_insn.
	
	PR target/15647
	Backport from mainline:
	* config/sh/t-linux (SHLIB_MAPFILES): Use sh specific
	libgcc-std.ver.
	* config/sh/libgcc-std.ver: New file.
	
	PR bootstrap/15120
	* libstdc++-v3/configure: Rebuilt.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.1006&r2=1.16114.2.1007
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sh/libgcc-std.ver.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.2.10.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sh/sh.md.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.133.2.3&r2=1.133.2.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sh/t-linux.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.6.20.2&r2=1.6.20.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.1464.2.188&r2=1.1464.2.189
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/configure.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.286.2.22&r2=1.286.2.23


------- Comment #10 From Andrew Pinski 2004-07-26 00:52 -------
Fixed also in 3.3.5

First Last Prev Next    No search results available      Search page      Enter new bug