public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/13373] New: optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore
@ 2003-12-10 10:38 olaf at bonorden dot de
2003-12-24 6:29 ` [Bug optimization/13373] " kazu at cs dot umass dot edu
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: olaf at bonorden dot de @ 2003-12-10 10:38 UTC (permalink / raw)
To: gcc-bugs
Compilation of a crc8 faild:
source:
unsigned short Calc_crc8(unsigned char data, unsigned short crc )
{
unsigned char i,x16,carry;
for (i = 0; i < 8; i++)
{
x16 = (unsigned char)((data & 1) ^ ((unsigned char)crc & 1));
data >>= 1;
if (x16 == 1)
{
crc ^= 0x4002;
carry = 1;
}
else carry = 0;
crc >>= 1;
if (carry)
crc |= 0x8000;
else
crc &= 0x7fff;
}
return crc;
}
-----------
Compilation with "mcore-be-elf-gcc -mbig-endian -O0 -frerun-cse-after-loop
crc.c -S" is ok,
with "mcore-be-elf-gcc -mbig-endian -O0 -frerun-cse-after-loop
-fexpensive-optimizations crc.c -S" the code is not correct.
Part in the produced assembler code:
first version:
ld.h r7,(r8,2)
bgeni r6,14
addi r6,2 // 16386 0x4002
xor r7,r6
st.h r7,(r8,2)
ldw r6,(r8,8)
st.b r6,(r8,6)
wrong second version:
ld.h r7,(r8,2)
st.h r7,(r8,2)
ldw r7,(r8,8)
st.b r7,(r8,6)
The xor part is removed :-(
Compiler without optimization is nearly useless.
--
Summary: optimization with -frerun-cse-after-loop -fexpensive-
optimizations produces wrong code on mcore
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: olaf at bonorden dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: mcore-be-elf
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13373
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug optimization/13373] optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore
2003-12-10 10:38 [Bug optimization/13373] New: optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore olaf at bonorden dot de
2003-12-24 6:29 ` [Bug optimization/13373] " kazu at cs dot umass dot edu
@ 2003-12-24 6:29 ` kazu at cs dot umass dot edu
2003-12-24 6:29 ` kazu at cs dot umass dot edu
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: kazu at cs dot umass dot edu @ 2003-12-24 6:29 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From kazu at cs dot umass dot edu 2003-12-24 05:49 -------
In my reduced case, xor is removed during the first cse pass.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13373
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug optimization/13373] optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore
2003-12-10 10:38 [Bug optimization/13373] New: optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore olaf at bonorden dot de
@ 2003-12-24 6:29 ` kazu at cs dot umass dot edu
2003-12-24 6:29 ` kazu at cs dot umass dot edu
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: kazu at cs dot umass dot edu @ 2003-12-24 6:29 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From kazu at cs dot umass dot edu 2003-12-24 05:30 -------
Confirmed on 3.3.
Not the case on mainline.
Reduced to:
short
foo (short crc)
{
if (crc)
crc ^= 0x4002;
return crc;
}
With -O1 instead of -O0, the difference is easier to see:
foo:
zexth r2
cmpnei r2,0
jbf .L2
- bgeni r7,14
- addi r7,2 // 16386 0x4002
- xor r2,r7
+ zexth r2
.L2:
sexth r2
jmp r15
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |kazu at cs dot umass dot edu
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2003-12-24 05:30:51
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13373
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug optimization/13373] optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore
2003-12-10 10:38 [Bug optimization/13373] New: optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore olaf at bonorden dot de
2003-12-24 6:29 ` [Bug optimization/13373] " kazu at cs dot umass dot edu
2003-12-24 6:29 ` kazu at cs dot umass dot edu
@ 2003-12-24 6:29 ` kazu at cs dot umass dot edu
2003-12-24 16:21 ` [Bug target/13373] " kazu at cs dot umass dot edu
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: kazu at cs dot umass dot edu @ 2003-12-24 6:29 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From kazu at cs dot umass dot edu 2003-12-24 05:52 -------
Reduced to:
short
foo (short crc)
{
return crc ^ 0x4002;
}
The problem still seems to be cse.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13373
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/13373] optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore
2003-12-10 10:38 [Bug optimization/13373] New: optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore olaf at bonorden dot de
` (2 preceding siblings ...)
2003-12-24 6:29 ` kazu at cs dot umass dot edu
@ 2003-12-24 16:21 ` kazu at cs dot umass dot edu
2003-12-24 21:11 ` [Bug target/13373] [3.3 only] " pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: kazu at cs dot umass dot edu @ 2003-12-24 16:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From kazu at cs dot umass dot edu 2003-12-24 15:30 -------
Backporting the following patch fixes the problem.
http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00044.html
I haven't run the testsuite though.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |rsandifo at redhat dot com
Component|optimization |target
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13373
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/13373] [3.3 only] optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore
2003-12-10 10:38 [Bug optimization/13373] New: optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore olaf at bonorden dot de
` (3 preceding siblings ...)
2003-12-24 16:21 ` [Bug target/13373] " kazu at cs dot umass dot edu
@ 2003-12-24 21:11 ` pinskia at gcc dot gnu dot org
2003-12-24 21:32 ` kazu at cs dot umass dot edu
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-24 21:11 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Summary|optimization with -frerun- |[3.3 only] optimization with
|cse-after-loop -fexpensive- |-frerun-cse-after-loop -
|optimizations produces wrong|fexpensive-optimizations
|code on mcore |produces wrong code on mcore
Target Milestone|--- |3.3.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13373
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/13373] [3.3 only] optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore
2003-12-10 10:38 [Bug optimization/13373] New: optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore olaf at bonorden dot de
` (4 preceding siblings ...)
2003-12-24 21:11 ` [Bug target/13373] [3.3 only] " pinskia at gcc dot gnu dot org
@ 2003-12-24 21:32 ` kazu at cs dot umass dot edu
2003-12-24 21:43 ` [Bug target/13373] [3.3 regression] " kazu at cs dot umass dot edu
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: kazu at cs dot umass dot edu @ 2003-12-24 21:32 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From kazu at cs dot umass dot edu 2003-12-24 21:20 -------
OK with 3.2 branch, so this is a regression from 3.2.x.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13373
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/13373] [3.3 regression] optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore
2003-12-10 10:38 [Bug optimization/13373] New: optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore olaf at bonorden dot de
` (5 preceding siblings ...)
2003-12-24 21:32 ` kazu at cs dot umass dot edu
@ 2003-12-24 21:43 ` kazu at cs dot umass dot edu
2003-12-29 18:55 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: kazu at cs dot umass dot edu @ 2003-12-24 21:43 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From kazu at cs dot umass dot edu 2003-12-24 21:38 -------
Here is a patch:
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02057.html
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13373
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/13373] [3.3 regression] optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore
2003-12-10 10:38 [Bug optimization/13373] New: optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore olaf at bonorden dot de
` (6 preceding siblings ...)
2003-12-24 21:43 ` [Bug target/13373] [3.3 regression] " kazu at cs dot umass dot edu
@ 2003-12-29 18:55 ` pinskia at gcc dot gnu dot org
2004-01-01 0:24 ` cvs-commit at gcc dot gnu dot org
2004-01-01 0:28 ` kazu at cs dot umass dot edu
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-29 18:55 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |critical
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13373
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/13373] [3.3 regression] optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore
2003-12-10 10:38 [Bug optimization/13373] New: optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore olaf at bonorden dot de
` (7 preceding siblings ...)
2003-12-29 18:55 ` pinskia at gcc dot gnu dot org
@ 2004-01-01 0:24 ` cvs-commit at gcc dot gnu dot org
2004-01-01 0:28 ` kazu at cs dot umass dot edu
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-01-01 0:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-01-01 00:24 -------
Subject: Bug 13373
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-3_3-branch
Changes by: kazu@gcc.gnu.org 2004-01-01 00:24:24
Modified files:
gcc : ChangeLog
gcc/config/mcore: mcore-protos.h mcore.c mcore.h mcore.md
Log message:
Backport from mainline:
2003-09-12 Richard Sandiford <rsandifo@redhat.com>
PR target/13373
* config/mcore/mcore-protos.h (mcore_r15_operand_p): Declare.
(mcore_secondary_reload_class): Declare.
(mcore_output_inline_const_forced): Remove.
* config/mcore/mcore.md (movsi): Remove the code that forced
non-inlineable constants into a register if the target was r15
or the stack pointer. Remove constant restrictions from the main
define_insn. Remove r <- I, r <- M and r <- N alternatives in favor
of an r <- P alternative. Remove fallback define_insn for reload.
(movhi, movqi): Use gen_lowpart rather than gen_SUBREG. Remove reload
define_insn. Use mcore_output_move in the remaining define_insn.
Adjust condition and constraints in the way as for movsi.
(movdi): Always split unacceptable constants into two. Use
simplify_gen_subreg instead of operand_subword{,_force}.
* config/mcore/mcore.c (mcore_output_inline_const_forced): Remove.
(mcore_output_move): Support HImode and QImode moves as well.
(mcore_m15_operand_p): New function.
(mcore_reload_class): Use it to detect cases where LRW_REGS are better.
(mcore_secondary_reload_class): New function.
* config/mcore/mcore.h (SECONDARY_RELOAD_CLASS): Redefine in
terms of mcore_secondary_reload_class.
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.863&r2=1.16114.2.864
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/mcore/mcore-protos.h.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.10&r2=1.10.20.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/mcore/mcore.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.40&r2=1.40.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/mcore/mcore.h.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.41.4.1&r2=1.41.4.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/mcore/mcore.md.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.7.4.1&r2=1.7.4.2
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13373
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/13373] [3.3 regression] optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore
2003-12-10 10:38 [Bug optimization/13373] New: optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore olaf at bonorden dot de
` (8 preceding siblings ...)
2004-01-01 0:24 ` cvs-commit at gcc dot gnu dot org
@ 2004-01-01 0:28 ` kazu at cs dot umass dot edu
9 siblings, 0 replies; 11+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-01-01 0:28 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From kazu at cs dot umass dot edu 2004-01-01 00:28 -------
Just backported a fix.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13373
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2004-01-01 0:28 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-10 10:38 [Bug optimization/13373] New: optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore olaf at bonorden dot de
2003-12-24 6:29 ` [Bug optimization/13373] " kazu at cs dot umass dot edu
2003-12-24 6:29 ` kazu at cs dot umass dot edu
2003-12-24 6:29 ` kazu at cs dot umass dot edu
2003-12-24 16:21 ` [Bug target/13373] " kazu at cs dot umass dot edu
2003-12-24 21:11 ` [Bug target/13373] [3.3 only] " pinskia at gcc dot gnu dot org
2003-12-24 21:32 ` kazu at cs dot umass dot edu
2003-12-24 21:43 ` [Bug target/13373] [3.3 regression] " kazu at cs dot umass dot edu
2003-12-29 18:55 ` pinskia at gcc dot gnu dot org
2004-01-01 0:24 ` cvs-commit at gcc dot gnu dot org
2004-01-01 0:28 ` kazu at cs dot umass dot edu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).