public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/25128] New: [m68k] Suboptimal comparisons against 65536
@ 2005-11-27 23:28 kazu at gcc dot gnu dot org
2005-11-27 23:31 ` [Bug target/25128] " kazu at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: kazu at gcc dot gnu dot org @ 2005-11-27 23:28 UTC (permalink / raw)
To: gcc-bugs
Consider:
unsigned int bar (void);
void
foo (void)
{
unsigned int a = bar ();
if (65536 > a)
bar ();
}
./cc1 -quiet -O2 -fomit-frame-pointer generates
foo:
move.l %a2,-(%sp)
lea bar,%a2
jbsr (%a2)
cmp.l #65535,%d0
jbhi .L10
jbsr (%a2)
.L10:
move.l (%sp)+,%a2
rts
Note that
cmp.l #65535,%d0
jbhi .L10
can be replaced with
swap %d0
tst.w %d0
jbne .L10
A similar trick can be applied to signed comparisons as well.
--
Summary: [m68k] Suboptimal comparisons against 65536
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kazu at gcc dot gnu dot org
GCC target triplet: m68k-elf
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25128
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/25128] [m68k] Suboptimal comparisons against 65536
2005-11-27 23:28 [Bug target/25128] New: [m68k] Suboptimal comparisons against 65536 kazu at gcc dot gnu dot org
@ 2005-11-27 23:31 ` kazu at gcc dot gnu dot org
2005-11-28 5:04 ` pinskia at gcc dot gnu dot org
2008-06-10 16:02 ` gunnar at greyhound-data dot com
2 siblings, 0 replies; 4+ messages in thread
From: kazu at gcc dot gnu dot org @ 2005-11-27 23:31 UTC (permalink / raw)
To: gcc-bugs
--
kazu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25128
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/25128] [m68k] Suboptimal comparisons against 65536
2005-11-27 23:28 [Bug target/25128] New: [m68k] Suboptimal comparisons against 65536 kazu at gcc dot gnu dot org
2005-11-27 23:31 ` [Bug target/25128] " kazu at gcc dot gnu dot org
@ 2005-11-28 5:04 ` pinskia at gcc dot gnu dot org
2008-06-10 16:02 ` gunnar at greyhound-data dot com
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-28 5:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2005-11-28 05:04 -------
Confirmed.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2005-11-28 05:04:23
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25128
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/25128] [m68k] Suboptimal comparisons against 65536
2005-11-27 23:28 [Bug target/25128] New: [m68k] Suboptimal comparisons against 65536 kazu at gcc dot gnu dot org
2005-11-27 23:31 ` [Bug target/25128] " kazu at gcc dot gnu dot org
2005-11-28 5:04 ` pinskia at gcc dot gnu dot org
@ 2008-06-10 16:02 ` gunnar at greyhound-data dot com
2 siblings, 0 replies; 4+ messages in thread
From: gunnar at greyhound-data dot com @ 2008-06-10 16:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from gunnar at greyhound-data dot com 2008-06-10 16:02 -------
> Note that
>
> cmp.l #65535,%d0
> jbhi .L10
>
> can be replaced with
>
> swap %d0
> tst.w %d0
> jbne .L10
>
> A similar trick can be applied to signed comparisons as well.
But this "trick" will run slower on the higher 68k CPUs.
On 68040 or 68060 or SuperScalar Coldfire its better to generate less
instructions that do not have dependancies.
I think "cmp.l #65535,%d0" is the code that should be generated by "O2" as its
faster on many 68K models.
The shorter two instruction trick might be an option for compile optiont "Os"
Kind regards
Gunnar von Boehn
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25128
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-06-10 16:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-27 23:28 [Bug target/25128] New: [m68k] Suboptimal comparisons against 65536 kazu at gcc dot gnu dot org
2005-11-27 23:31 ` [Bug target/25128] " kazu at gcc dot gnu dot org
2005-11-28 5:04 ` pinskia at gcc dot gnu dot org
2008-06-10 16:02 ` gunnar at greyhound-data dot com
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).