public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/94786] New: Missed min/max pattern using xor+and+less
@ 2020-04-27  8:11 gabravier at gmail dot com
  2020-04-27 10:29 ` [Bug tree-optimization/94786] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gabravier at gmail dot com @ 2020-04-27  8:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94786
           Summary: Missed min/max pattern using xor+and+less
           Product: gcc
           Version: 10.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: ---

int r1(int x, int y)
{
    return y ^ ((x ^ y) & -(x < y));
}

int r2(int x, int y)
{
    return x ^ ((x ^ y) & -(x < y));
}

`r1` can be optimized to `min` and `r2` to `max`. This transformation is done
by LLVM, but not by GCC.

Comparison here: https://godbolt.org/z/hNhkqM

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

* [Bug tree-optimization/94786] Missed min/max pattern using xor+and+less
  2020-04-27  8:11 [Bug tree-optimization/94786] New: Missed min/max pattern using xor+and+less gabravier at gmail dot com
@ 2020-04-27 10:29 ` rguenth at gcc dot gnu.org
  2020-05-07 16:31 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-04-27 10:29 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-04-27
           Keywords|                            |easyhack
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

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

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

* [Bug tree-optimization/94786] Missed min/max pattern using xor+and+less
  2020-04-27  8:11 [Bug tree-optimization/94786] New: Missed min/max pattern using xor+and+less gabravier at gmail dot com
  2020-04-27 10:29 ` [Bug tree-optimization/94786] " rguenth at gcc dot gnu.org
@ 2020-05-07 16:31 ` jakub at gcc dot gnu.org
  2020-05-07 16:44 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-05-07 16:31 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Seems this is PR92834 just using ^ instead of -.

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

* [Bug tree-optimization/94786] Missed min/max pattern using xor+and+less
  2020-04-27  8:11 [Bug tree-optimization/94786] New: Missed min/max pattern using xor+and+less gabravier at gmail dot com
  2020-04-27 10:29 ` [Bug tree-optimization/94786] " rguenth at gcc dot gnu.org
  2020-05-07 16:31 ` jakub at gcc dot gnu.org
@ 2020-05-07 16:44 ` jakub at gcc dot gnu.org
  2020-05-08  8:55 ` cvs-commit at gcc dot gnu.org
  2020-05-08  8:56 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-05-07 16:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 48475
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48475&action=edit
gcc11-pr94786.patch

Untested fix.

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

* [Bug tree-optimization/94786] Missed min/max pattern using xor+and+less
  2020-04-27  8:11 [Bug tree-optimization/94786] New: Missed min/max pattern using xor+and+less gabravier at gmail dot com
                   ` (2 preceding siblings ...)
  2020-05-07 16:44 ` jakub at gcc dot gnu.org
@ 2020-05-08  8:55 ` cvs-commit at gcc dot gnu.org
  2020-05-08  8:56 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-05-08  8:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:1595a1cb7bfac8d5a6026d5d6f3a495be0391506

commit r11-198-g1595a1cb7bfac8d5a6026d5d6f3a495be0391506
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri May 8 10:52:47 2020 +0200

    match.pd: A ^ ((A ^ B) & -(C cmp D)) -> (C cmp D) ? B : A simplification
[PR94786]

    We already have x - ((x - y) & -(z < w)) and
    x + ((y - x) & -(z < w)) simplifications, this one adds
    x ^ ((x ^ y) & -(z < w)) (not merged using for because of the
    :c that can be present on bit_xor and can't on minus).

    2020-05-08  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/94786
            * match.pd (A ^ ((A ^ B) & -(C cmp D)) -> (C cmp D) ? B : A): New
            simplification.

            * gcc.dg/tree-ssa/pr94786.c: New test.

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

* [Bug tree-optimization/94786] Missed min/max pattern using xor+and+less
  2020-04-27  8:11 [Bug tree-optimization/94786] New: Missed min/max pattern using xor+and+less gabravier at gmail dot com
                   ` (3 preceding siblings ...)
  2020-05-08  8:55 ` cvs-commit at gcc dot gnu.org
@ 2020-05-08  8:56 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-05-08  8:56 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2020-05-08  8:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-27  8:11 [Bug tree-optimization/94786] New: Missed min/max pattern using xor+and+less gabravier at gmail dot com
2020-04-27 10:29 ` [Bug tree-optimization/94786] " rguenth at gcc dot gnu.org
2020-05-07 16:31 ` jakub at gcc dot gnu.org
2020-05-07 16:44 ` jakub at gcc dot gnu.org
2020-05-08  8:55 ` cvs-commit at gcc dot gnu.org
2020-05-08  8:56 ` 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).