public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/109424] New: ~
@ 2023-04-05 19:47 pinskia at gcc dot gnu.org
  2023-04-05 19:47 ` [Bug tree-optimization/109424] ~((x > y) ? x : y) produces two not instructions pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-05 19:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109424
           Summary: ~
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: pinskia at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
int f(int x, int y)
{
    int t = ((x > y) ? x : y);
    return ~t;
}
int f1(int x, int y)
{
    return ~((x > y) ? x : y);
}
```
You would assume GCC produce the same code for both, but nope, the first f is
worse.

The reason why is GCC decides to move the ~ into the ?: operator making the
code worse.

fold does this "optimization" but nothing undones it, phi-opt undones it for
casts in some but not all cases.

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

end of thread, other threads:[~2023-05-16  3:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-05 19:47 [Bug tree-optimization/109424] New: ~ pinskia at gcc dot gnu.org
2023-04-05 19:47 ` [Bug tree-optimization/109424] ~((x > y) ? x : y) produces two not instructions pinskia at gcc dot gnu.org
2023-04-05 19:48 ` pinskia at gcc dot gnu.org
2023-04-07 16:29 ` roger at nextmovesoftware dot com
2023-04-16 18:32 ` pinskia at gcc dot gnu.org
2023-05-08  7:38 ` cvs-commit at gcc dot gnu.org
2023-05-08  7:39 ` pinskia at gcc dot gnu.org
2023-05-08  7:41 ` pinskia at gcc dot gnu.org
2023-05-16  3:50 ` cvs-commit 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).