public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/23664] New: fold does not change (a&C1)+(b&C2) to (a&C1)|(b&C2) iff (C1 & C2) == 0
Date: Thu, 01 Sep 2005 00:40:00 -0000	[thread overview]
Message-ID: <20050901004014.23664.pinskia@gcc.gnu.org> (raw)

These two functions should produce the same asm:
int f(int a, int b)
{
  return (a&0xF)+(b&0xF0);
}
int f1(int a, int b)
{
  return (a&0xF)|(b&0xF0);
}
For PPC, we get:
_f:
        rlwinm r4,r4,0,24,27
        rlwinm r3,r3,0,28,31
        add r3,r3,r4
        blr
_f1:
        rlwinm r4,r4,0,24,27
        rlwimi r3,r4,0,0,27
        blr

Which shows the | is more efficient than the + one.

-- 
           Summary: fold does not change (a&C1)+(b&C2) to (a&C1)|(b&C2) iff
                    (C1 & C2) == 0
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: powerpc-*-*
OtherBugsDependingO 19987
             nThis:


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


             reply	other threads:[~2005-09-01  0:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-01  0:40 pinskia at gcc dot gnu dot org [this message]
2005-09-01  0:42 ` [Bug middle-end/23664] " pinskia at gcc dot gnu dot org
2005-09-17  2:12 ` pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050901004014.23664.pinskia@gcc.gnu.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).