[Bug target/25112] New: [m68k] Inefficient equality comparison with small integers
kazu at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Sun Nov 27 02:11:00 GMT 2005
Consider:
int bar (void);
void
foo (void)
{
int a = bar ();
if (a == 1)
bar ();
}
./cc1 -quiet -O2 -m5200 -fomit-frame-pointer generates
foo:
move.l %a2,-(%sp)
lea bar,%a2
jbsr (%a2)
moveq #1,%d1
cmp.l %d0,%d1
jbne .L4
jbsr (%a2)
.L4:
move.l (%sp)+,%a2
rts
Note that
moveq #1,%d1
cmp.l %d0,%d1
can be replaced with
subq.l #1,%d1
as long as the comparison is either == or !=, and %d1 dies at the comparison.
A similar optimization can be done for an equality comparison with
a negative numbers between -8 and -1, inclusive.
--
Summary: [m68k] Inefficient equality comparison with small
integers
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
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=25112
More information about the Gcc-bugs
mailing list