public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/103535] New: [missed optimization] remainder-of-2 with subtract-1
@ 2021-12-02 22:17 jengelh at inai dot de
  2021-12-02 22:19 ` [Bug tree-optimization/103535] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jengelh at inai dot de @ 2021-12-02 22:17 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103535
           Summary: [missed optimization] remainder-of-2 with subtract-1
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jengelh at inai dot de
  Target Milestone: ---

gcc version 11.2.1 20210816 [revision 056e324ce46a7924b5cf10f61010cf9dd2ca10e9]
(SUSE Linux)  x86_64

== input ==
unsigned int fff(unsigned int p)
{
        // equivalent to  return p & ~1;
        if (p % 2 != 0)
                --p;
        return p;
}

== Observed output ==
» gcc -O2 -c x.cpp; objdump -Mintel -d x.o
   0:   89 fa                   mov    edx,edi
   2:   89 f8                   mov    eax,edi
   4:   83 e2 01                and    edx,0x1
   7:   83 fa 01                cmp    edx,0x1
   a:   83 d0 ff                adc    eax,0xffffffff
   d:   c3                      ret    

== Expected output ==
   0:   89 f8                   mov    eax,edi
   2:   83 e0 fe                and    eax,0xfffffffe
   5:   c3                      ret

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

* [Bug tree-optimization/103535] [missed optimization] remainder-of-2 with subtract-1
  2021-12-02 22:17 [Bug tree-optimization/103535] New: [missed optimization] remainder-of-2 with subtract-1 jengelh at inai dot de
@ 2021-12-02 22:19 ` pinskia at gcc dot gnu.org
  2021-12-02 22:35 ` pinskia at gcc dot gnu.org
  2021-12-02 22:40 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-02 22:19 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org
           Severity|normal                      |enhancement
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-12-02
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Mine for GCC 13.

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

* [Bug tree-optimization/103535] [missed optimization] remainder-of-2 with subtract-1
  2021-12-02 22:17 [Bug tree-optimization/103535] New: [missed optimization] remainder-of-2 with subtract-1 jengelh at inai dot de
  2021-12-02 22:19 ` [Bug tree-optimization/103535] " pinskia at gcc dot gnu.org
@ 2021-12-02 22:35 ` pinskia at gcc dot gnu.org
  2021-12-02 22:40 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-02 22:35 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=103216

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I have a patch which gets the optimized code (at least being able to generate
at the rtl level):
  _1 = p_3(D) & 1;
  _7 = _1 != 0;
  _6 = (unsigned int) _7;
  _9 = p_3(D) - _6;


        movl    %edi, %eax
        andl    $-2, %eax
        ret

The patch is the one for PR 103216.

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

* [Bug tree-optimization/103535] [missed optimization] remainder-of-2 with subtract-1
  2021-12-02 22:17 [Bug tree-optimization/103535] New: [missed optimization] remainder-of-2 with subtract-1 jengelh at inai dot de
  2021-12-02 22:19 ` [Bug tree-optimization/103535] " pinskia at gcc dot gnu.org
  2021-12-02 22:35 ` pinskia at gcc dot gnu.org
@ 2021-12-02 22:40 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-02 22:40 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|NEW                         |RESOLVED

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is actually an exact dup of bug 97711.

*** This bug has been marked as a duplicate of bug 97711 ***

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

end of thread, other threads:[~2021-12-02 22:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-02 22:17 [Bug tree-optimization/103535] New: [missed optimization] remainder-of-2 with subtract-1 jengelh at inai dot de
2021-12-02 22:19 ` [Bug tree-optimization/103535] " pinskia at gcc dot gnu.org
2021-12-02 22:35 ` pinskia at gcc dot gnu.org
2021-12-02 22:40 ` pinskia 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).