public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/66552] Missed optimization when shift amount is result of signed modulus
Date: Wed, 17 Jun 2015 19:33:00 -0000	[thread overview]
Message-ID: <bug-66552-4-PQCf4hRQ89@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-66552-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66552

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Target|x86/generic                 |x86, powerpc64

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
On powerpc64, with -O2, GCC emits the following 

f:
        srawi 9,4,5
        addze 9,9
        slwi 9,9,5
        subf 4,9,4
        srw 3,3,4
        rldicl 3,3,0,32
        blr

while Clang emits what looks like optimal code:

f:
        rlwinm 4, 4, 0, 27, 31
        srw 3, 3, 4
        blr

With the return expression rewritten as suggested (i.e., x >> (n & 31)), GCC
still emits an extra instruction compare to Clang.  I believe this aspect is
tracked in bug 66217.

        rldicl 4,4,0,59
        srw 3,3,4
        rldicl 3,3,0,32
        blr


       reply	other threads:[~2015-06-17 19:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-66552-4@http.gcc.gnu.org/bugzilla/>
2015-06-17 19:33 ` msebor at gcc dot gnu.org [this message]
2015-06-30  4:34 ` [Bug rtl-optimization/66552] " segher at gcc dot gnu.org
2015-06-30 15:52 ` msebor at gcc dot gnu.org
2020-10-19  9:27 ` cvs-commit at gcc dot gnu.org
2020-10-21  3:15 ` guojiufu at gcc dot gnu.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=bug-66552-4-PQCf4hRQ89@http.gcc.gnu.org/bugzilla/ \
    --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).