public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/10982] New: [arm] poor optimisation of "if (var & const)"
@ 2003-05-26 13:58 pb@gcc.gnu.org
  2003-06-22  3:29 ` [Bug optimization/10982] " pinskia at physics dot uc dot edu
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: pb@gcc.gnu.org @ 2003-05-26 13:58 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10982

           Summary: [arm] poor optimisation of "if (var & const)"
           Product: gcc
           Version: unknown
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: pb@gcc.gnu.org
                CC: gcc-bugs@gcc.gnu.org
GCC target triplet: arm-linux

Compiling this code:

f(int a)
{
  if (a & 0xfff)
    return 1;
  return 0;
}

with -O2 yields:

        mov     r0, r0, asl #20
        mov     r0, r0, lsr #20
        cmp     r0, #0
        movne   r0, #1
        moveq   r0, #0

There's no need to fully calculate the value of the AND, since all that we care
about is whether it's zero or not.  So, I think the first three instructions
could be replaced by a single one:

        movs     r0, r0, asl #20



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-05-16 22:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-26 13:58 [Bug optimization/10982] New: [arm] poor optimisation of "if (var & const)" pb@gcc.gnu.org
2003-06-22  3:29 ` [Bug optimization/10982] " pinskia at physics dot uc dot edu
2004-05-09 17:11 ` pb at gcc dot gnu dot org
2004-05-17 11:27 ` [Bug target/10982] " rearnsha at gcc dot gnu dot org
2004-05-17 11:32 ` cvs-commit at gcc dot gnu dot org
2004-05-17 11:38 ` rearnsha at gcc dot gnu dot org
2004-05-17 11:40 ` rearnsha at gcc dot gnu dot org

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).