public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/105983] New: Failure to optimize (b != 0) && (a >= b) as well as the same pattern with binary and
@ 2022-06-14 21:37 gabravier at gmail dot com
  2022-06-14 21:39 ` [Bug tree-optimization/105983] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: gabravier at gmail dot com @ 2022-06-14 21:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105983
           Summary: Failure to optimize (b != 0) && (a >= b) as well as
                    the same pattern with binary and
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

bool f(unsigned a, unsigned b)
{
    return (b != 0) && (a >= b);
}

This can be optimized to `return (b != 0) & (a >= b);`, which is itself
optimized to `return (b - 1) > a;`. GCC outputs code equivalent to `return (b
!= 0) & (a >= b);` (at least on x86) whereas if that code is compiled it would
output `return (b - 1) > a;`, while LLVM has no trouble directly outputting the
optimal code.

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

end of thread, other threads:[~2022-06-16 12:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-14 21:37 [Bug tree-optimization/105983] New: Failure to optimize (b != 0) && (a >= b) as well as the same pattern with binary and gabravier at gmail dot com
2022-06-14 21:39 ` [Bug tree-optimization/105983] " pinskia at gcc dot gnu.org
2022-06-14 21:41 ` pinskia at gcc dot gnu.org
2022-06-14 21:45 ` pinskia at gcc dot gnu.org
2022-06-15 12:26 ` jakub at gcc dot gnu.org
2022-06-15 13:32 ` jakub at gcc dot gnu.org
2022-06-15 14:13 ` rearnsha at gcc dot gnu.org
2022-06-15 14:20 ` rearnsha at gcc dot gnu.org
2022-06-15 14:50 ` jakub at gcc dot gnu.org
2022-06-16 12:37 ` cvs-commit at gcc dot gnu.org
2022-06-16 12:39 ` jakub 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).