public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/94589] New: Optimize (i<=>0)>0 to i>0
@ 2020-04-14  6:57 glisse at gcc dot gnu.org
  2020-04-14 10:43 ` [Bug tree-optimization/94589] " rguenth at gcc dot gnu.org
                   ` (26 more replies)
  0 siblings, 27 replies; 28+ messages in thread
From: glisse at gcc dot gnu.org @ 2020-04-14  6:57 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94589
           Summary: Optimize (i<=>0)>0 to i>0
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: glisse at gcc dot gnu.org
  Target Milestone: ---

g++-10 -std=gu++2a -O3

#include <compare>
bool k(int i){
  auto c=i<=>0;
  return c>0;
}

  <bb 2> [local count: 1073741824]:
  if (i_1(D) != 0)
    goto <bb 3>; [50.00%]
  else
    goto <bb 4>; [50.00%]

  <bb 3> [local count: 536870913]:
  _2 = i_1(D) >= 0;

  <bb 4> [local count: 1073741824]:
  # prephitmp_6 = PHI <_2(3), 0(2)>
  return prephitmp_6;

For most comparisons @ we do optimize (i<=>0)@0 to just i@0, but not for > and
<=. Spaceship operator<=> is very painful to use, but I expect we will end up
seeing a lot of it with C++20, and comparing its result with 0 is almost the
only way to use its output, so it seems important to optimize this common case.

(there is probably a very old dup, but I couldn't find it)

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

end of thread, other threads:[~2023-09-13 18:09 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-14  6:57 [Bug tree-optimization/94589] New: Optimize (i<=>0)>0 to i>0 glisse at gcc dot gnu.org
2020-04-14 10:43 ` [Bug tree-optimization/94589] " rguenth at gcc dot gnu.org
2020-06-05 15:31 ` khim at google dot com
2021-04-29  8:55 ` redi at gcc dot gnu.org
2021-04-29  8:57 ` redi at gcc dot gnu.org
2021-04-29  9:21 ` redi at gcc dot gnu.org
2021-04-29 10:07 ` rguenth at gcc dot gnu.org
2021-04-29 10:25 ` glisse at gcc dot gnu.org
2021-04-29 10:28 ` glisse at gcc dot gnu.org
2021-04-29 10:33 ` redi at gcc dot gnu.org
2021-04-29 10:33 ` redi at gcc dot gnu.org
2021-04-29 10:39 ` rguenther at suse dot de
2021-04-29 11:06 ` glisse at gcc dot gnu.org
2021-04-29 11:49 ` rguenth at gcc dot gnu.org
2021-04-29 12:55 ` rguenth at gcc dot gnu.org
2021-04-29 13:29 ` jakub at gcc dot gnu.org
2021-04-29 15:48 ` jakub at gcc dot gnu.org
2021-04-29 17:41 ` jakub at gcc dot gnu.org
2021-04-30 17:23 ` jakub at gcc dot gnu.org
2021-05-03 17:09 ` jakub at gcc dot gnu.org
2021-05-06  8:18 ` cvs-commit at gcc dot gnu.org
2021-05-12  7:48 ` cvs-commit at gcc dot gnu.org
2021-05-18  8:09 ` cvs-commit at gcc dot gnu.org
2021-05-18  8:11 ` jakub at gcc dot gnu.org
2021-05-20  7:11 ` cvs-commit at gcc dot gnu.org
2021-05-21  8:40 ` cvs-commit at gcc dot gnu.org
2021-08-27  6:15 ` pinskia at gcc dot gnu.org
2023-09-13 18:09 ` 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).