public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/66706] New: Redundant shift instruction on x >> (n & 32)
@ 2015-06-30 15:49 msebor at gcc dot gnu.org
  2015-06-30 16:20 ` [Bug rtl-optimization/66706] Redundant bitmask " segher at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: msebor at gcc dot gnu.org @ 2015-06-30 15:49 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66706
           Summary: Redundant shift instruction on x >> (n & 32)
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
                CC: mpolacek at gcc dot gnu.org, msebor at gcc dot gnu.org,
                    rv at rasmusvillemoes dot dk, segher at gcc dot gnu.org,
                    unassigned at gcc dot gnu.org
        Depends on: 66552
  Target Milestone: ---
            Target: x86, powerpc64

+++ This bug was initially created as a clone of Bug #66552 +++

Compiling the following function with -O2:

        unsigned f(unsigned x, int n)
        {
            return x >> (n & 32);
        }

results in an unnecessary instruction to zero out the already clear high order
bits of register 3 after the shift instruction:

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

Clang emits an optimal sequence:

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


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66552
[Bug 66552] Missed optimization when shift amount is result of signed modulus


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

end of thread, other threads:[~2020-10-21  3:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-30 15:49 [Bug rtl-optimization/66706] New: Redundant shift instruction on x >> (n & 32) msebor at gcc dot gnu.org
2015-06-30 16:20 ` [Bug rtl-optimization/66706] Redundant bitmask " segher at gcc dot gnu.org
2015-07-02 16:27 ` segher at gcc dot gnu.org
2015-07-02 16:30 ` segher at gcc dot gnu.org
2015-07-03 14:38 ` segher at gcc dot gnu.org
2020-10-21  3:15 ` guojiufu at gcc dot gnu.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).