Bug 25114 - [m68k] Suboptimal inequality comparisons with small integers
Summary: [m68k] Suboptimal inequality comparisons with small integers
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.2.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on: 25113
Blocks:
  Show dependency treegraph
 
Reported: 2005-11-27 02:36 UTC by Kazu Hirata
Modified: 2016-01-20 07:56 UTC (History)
2 users (show)

See Also:
Host:
Target: m68k-elf
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-11-28 05:05:10


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kazu Hirata 2005-11-27 02:36:02 UTC
Consider:

unsigned int bar (void);

void
foo (void)
{
  unsigned int a = bar ();
  if (a <= 3)
    bar ();
}

./cc1 -quiet -O2 -fomit-frame-pointer generates

foo:
        move.l %a2,-(%sp)
        lea bar,%a2
        jbsr (%a2)
        moveq #3,%d1
        cmp.l %d0,%d1
        jbcs .L4
        jbsr (%a2)
.L4:
        move.l (%sp)+,%a2
        rts

Note that

        moveq #3,%d1
        cmp.l %d0,%d1
        jbcs .L4

can be replaced with

        lsr.l #2,%d0
        jbne .L4

This bug depends on PR 25113 because GCC needs to know that lsr.l sets
the zero flag correctly.
Comment 1 Andrew Pinski 2005-11-28 05:05:10 UTC
Confirmed.
Comment 2 Jeffrey A. Law 2016-01-20 07:56:53 UTC
Fixed on the trunk.