public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/98907] New: Failure to optimize abs pattern
@ 2021-02-01  7:48 gabravier at gmail dot com
  2021-02-02  7:56 ` [Bug tree-optimization/98907] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: gabravier at gmail dot com @ 2021-02-01  7:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98907
           Summary: Failure to optimize abs pattern
           Product: gcc
           Version: 11.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: ---

int32_t f(int32_t x)
{
    return ((x >> 31) | 1) * x;
}

This can be optimized into `return __builtin_abs(x);` (where sizeof(int) ==
sizeof(int32_t)). This transformation is done by LLVM, but not GCC.

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

* [Bug tree-optimization/98907] Failure to optimize abs pattern
  2021-02-01  7:48 [Bug tree-optimization/98907] New: Failure to optimize abs pattern gabravier at gmail dot com
@ 2021-02-02  7:56 ` rguenth at gcc dot gnu.org
  2021-07-25  5:50 ` pinskia at gcc dot gnu.org
  2023-09-04  9:10 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-02-02  7:56 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-02-02
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.

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

* [Bug tree-optimization/98907] Failure to optimize abs pattern
  2021-02-01  7:48 [Bug tree-optimization/98907] New: Failure to optimize abs pattern gabravier at gmail dot com
  2021-02-02  7:56 ` [Bug tree-optimization/98907] " rguenth at gcc dot gnu.org
@ 2021-07-25  5:50 ` pinskia at gcc dot gnu.org
  2023-09-04  9:10 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-25  5:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
What LLVM does is the following:
((x >> 31) | 1) * x;

Convert (x >> 31) into -(x < 0)

(-(x < 0)) | -> x < 0 ? -1 : 1

(x < 0 ? -1 : 1) *x -> x < 0 ? -x : x

Now we could do the same I don't know to do this way or another way.

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

* [Bug tree-optimization/98907] Failure to optimize abs pattern
  2021-02-01  7:48 [Bug tree-optimization/98907] New: Failure to optimize abs pattern gabravier at gmail dot com
  2021-02-02  7:56 ` [Bug tree-optimization/98907] " rguenth at gcc dot gnu.org
  2021-07-25  5:50 ` pinskia at gcc dot gnu.org
@ 2023-09-04  9:10 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-04  9:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Mine,
bug 110009 comment #3 has the patch for this and that one.

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

end of thread, other threads:[~2023-09-04  9:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01  7:48 [Bug tree-optimization/98907] New: Failure to optimize abs pattern gabravier at gmail dot com
2021-02-02  7:56 ` [Bug tree-optimization/98907] " rguenth at gcc dot gnu.org
2021-07-25  5:50 ` pinskia at gcc dot gnu.org
2023-09-04  9:10 ` 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).