public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/66552] Missed optimization when shift amount is result of signed modulus
       [not found] <bug-66552-4@http.gcc.gnu.org/bugzilla/>
@ 2015-06-17 19:33 ` msebor at gcc dot gnu.org
  2015-06-30  4:34 ` [Bug rtl-optimization/66552] " segher at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2015-06-17 19:33 UTC (permalink / raw)
  To: gcc-bugs

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


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

* [Bug rtl-optimization/66552] Missed optimization when shift amount is result of signed modulus
       [not found] <bug-66552-4@http.gcc.gnu.org/bugzilla/>
  2015-06-17 19:33 ` [Bug c/66552] Missed optimization when shift amount is result of signed modulus msebor at gcc dot gnu.org
@ 2015-06-30  4:34 ` segher at gcc dot gnu.org
  2015-06-30 15:52 ` msebor at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: segher at gcc dot gnu.org @ 2015-06-30  4:34 UTC (permalink / raw)
  To: gcc-bugs

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

Segher Boessenkool <segher at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-06-30
                 CC|                            |segher at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Segher Boessenkool <segher at gcc dot gnu.org> ---
Please file a separate bug for that last problem (it seems to be a
combine problem; it has nothing to do with PR66217).  You can assign
it to me if you want.

Confirmed, btw.


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

* [Bug rtl-optimization/66552] Missed optimization when shift amount is result of signed modulus
       [not found] <bug-66552-4@http.gcc.gnu.org/bugzilla/>
  2015-06-17 19:33 ` [Bug c/66552] Missed optimization when shift amount is result of signed modulus msebor at gcc dot gnu.org
  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
  4 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2015-06-30 15:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
(In reply to Segher Boessenkool from comment #2)

I opened bug 66706.


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

* [Bug rtl-optimization/66552] Missed optimization when shift amount is result of signed modulus
       [not found] <bug-66552-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-10-19  9:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jiu Fu Guo <guojiufu@gcc.gnu.org>:

https://gcc.gnu.org/g:222f312a773157f53396ba4cb287deb07f84cc34

commit r11-4033-g222f312a773157f53396ba4cb287deb07f84cc34
Author: guojiufu <guojiufu@linux.ibm.com>
Date:   Mon Oct 19 13:48:19 2020 +0800

    [PATCH] fold x << (n % C) to x << (n & C-1) if C meets power2

    This patch fixes PR66552 which is also as:
    https://gcc.gnu.org/pipermail/gcc-patches/2020-February/540930.html
    which requests to optimizes (x shift (n mod C)) to
    (x shift (n bit_and (C - 1))) when C is a constant and power of two.

    gcc/ChangeLog
    2020-10-19  Li Jia He  <helijia@gcc.gnu.org>

            PR tree-optimization/66552
            * match.pd (x << (n % C) -> x << (n & C-1)): New simplification.

    gcc/testsuite/ChangeLog
    2020-10-19  Li Jia He  <helijia@gcc.gnu.org>

            PR tree-optimization/66552
            * gcc.dg/pr66552.c: New testcase.

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

* [Bug rtl-optimization/66552] Missed optimization when shift amount is result of signed modulus
       [not found] <bug-66552-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2020-10-19  9:27 ` cvs-commit at gcc dot gnu.org
@ 2020-10-21  3:15 ` guojiufu at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: guojiufu at gcc dot gnu.org @ 2020-10-21  3:15 UTC (permalink / raw)
  To: gcc-bugs

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

Jiu Fu Guo <guojiufu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |guojiufu at gcc dot gnu.org
         Resolution|---                         |FIXED

--- Comment #16 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> ---
Just confirmed the fix is ready in the trunk.

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-66552-4@http.gcc.gnu.org/bugzilla/>
2015-06-17 19:33 ` [Bug c/66552] Missed optimization when shift amount is result of signed modulus msebor at gcc dot gnu.org
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

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