public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/101116] New: missed peephole optimization not of bitwise and
@ 2021-06-18  5:17 hiraditya at msn dot com
  2021-06-18  5:35 ` [Bug target/101116] " pinskia at gcc dot gnu.org
  2021-06-18  5:42 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: hiraditya at msn dot com @ 2021-06-18  5:17 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101116
           Summary: missed peephole optimization not of bitwise and
           Product: gcc
           Version: 11.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hiraditya at msn dot com
  Target Milestone: ---

$ cat test.c

bool foo(unsigned i) {
    return !(i & 1);
}

gcc -O2 test.c -S -o-
foo(unsigned int):
        mov     eax, edi
        not     eax
        and     eax, 1
        ret

clang -O2 test.c -S -o-

foo(unsigned int): # @foo(unsigned int)
  testb $1, %dil
  sete %al
  retq


Ref: https://godbolt.org/z/Tndb1dM8Y

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

* [Bug target/101116] missed peephole optimization not of bitwise and
  2021-06-18  5:17 [Bug tree-optimization/101116] New: missed peephole optimization not of bitwise and hiraditya at msn dot com
@ 2021-06-18  5:35 ` pinskia at gcc dot gnu.org
  2021-06-18  5:42 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-18  5:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|tree-optimization           |target

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
It is an open question which is better.

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

* [Bug target/101116] missed peephole optimization not of bitwise and
  2021-06-18  5:17 [Bug tree-optimization/101116] New: missed peephole optimization not of bitwise and hiraditya at msn dot com
  2021-06-18  5:35 ` [Bug target/101116] " pinskia at gcc dot gnu.org
@ 2021-06-18  5:42 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-18  5:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Take:
unsigned char foo(unsigned *i) {
    return !(*i & 1);
}

GCC and clang/LLVM produce similar code.  In fact similar to what GCC produces
before.

Note also ICC produces the same code as GCC for original case.  So does
Microsoft compiler.  So I think we can say this is not a missed optimization
for GCC.

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

end of thread, other threads:[~2021-06-18  5:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18  5:17 [Bug tree-optimization/101116] New: missed peephole optimization not of bitwise and hiraditya at msn dot com
2021-06-18  5:35 ` [Bug target/101116] " pinskia at gcc dot gnu.org
2021-06-18  5:42 ` 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).