public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/97711] New: Failure to optimise "x & 1 ? x - 1 : x" to "x & -2"
@ 2020-11-04  0:50 rsandifo at gcc dot gnu.org
  2020-11-04  8:33 ` [Bug tree-optimization/97711] " rguenth at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2020-11-04  0:50 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97711
           Summary: Failure to optimise "x & 1 ? x - 1 : x" to "x & -2"
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rsandifo at gcc dot gnu.org
  Target Milestone: ---

GCC doesn't optimise the expression:

  int f (int x) { return x & 1 ? x - 1 : x; }

to x & -2 (but clang does).  The original motivation was actually:

  char *g (char *x) { return (__UINTPTR_TYPE__) x & 1 ? x - 1 : x; }

which I guess might require a different pattern.

(And the reason for writing g that way was to do all pointer
arithmetic on pointers rather than converting to a uintptr_t,
doing arithmetic, and converting back.)

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

end of thread, other threads:[~2023-06-09 14:21 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-04  0:50 [Bug tree-optimization/97711] New: Failure to optimise "x & 1 ? x - 1 : x" to "x & -2" rsandifo at gcc dot gnu.org
2020-11-04  8:33 ` [Bug tree-optimization/97711] " rguenth at gcc dot gnu.org
2021-07-20  5:56 ` pinskia at gcc dot gnu.org
2021-11-15  0:33 ` pinskia at gcc dot gnu.org
2021-11-15  0:34 ` pinskia at gcc dot gnu.org
2021-11-15  0:40 ` pinskia at gcc dot gnu.org
2021-12-02 22:40 ` pinskia at gcc dot gnu.org
2021-12-02 22:40 ` pinskia at gcc dot gnu.org
2023-06-07 15:12 ` pinskia at gcc dot gnu.org
2023-06-07 15:55 ` pinskia at gcc dot gnu.org
2023-06-07 21:36 ` pinskia at gcc dot gnu.org
2023-06-09 14:16 ` cvs-commit at gcc dot gnu.org
2023-06-09 14:19 ` pinskia at gcc dot gnu.org
2023-06-09 14:21 ` 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).