public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/112356] New: `x == MIN & x > y` is not optimized to 0 if x was casted to signed from unsigned
@ 2023-11-02 20:53 pinskia at gcc dot gnu.org
  2023-11-02 20:53 ` [Bug tree-optimization/112356] " pinskia at gcc dot gnu.org
  2023-11-02 21:00 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-02 20:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112356
           Summary: `x == MIN & x > y` is not optimized to 0 if x was
                    casted to signed from unsigned
           Product: gcc
           Version: 14.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:
```
#include <limits.h>

signed f2_1( unsigned x,  signed y)
{
   signed xs = x;
   signed t = x == INT_MIN;
   signed t1 = xs > y;
  return t & t1;
}
```

This is not optimized to 0.

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

* [Bug tree-optimization/112356] `x == MIN & x > y` is not optimized to 0 if x was casted to signed from unsigned
  2023-11-02 20:53 [Bug tree-optimization/112356] New: `x == MIN & x > y` is not optimized to 0 if x was casted to signed from unsigned pinskia at gcc dot gnu.org
@ 2023-11-02 20:53 ` pinskia at gcc dot gnu.org
  2023-11-02 21:00 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-02 20:53 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-11-02

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

* [Bug tree-optimization/112356] `x == MIN & x > y` is not optimized to 0 if x was casted to signed from unsigned
  2023-11-02 20:53 [Bug tree-optimization/112356] New: `x == MIN & x > y` is not optimized to 0 if x was casted to signed from unsigned pinskia at gcc dot gnu.org
  2023-11-02 20:53 ` [Bug tree-optimization/112356] " pinskia at gcc dot gnu.org
@ 2023-11-02 21:00 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-02 21:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The problem is we can't use `(match min_value` here but rather we need to
change it from:
```
(for eqne (eq ne)
 (simplify
  (bit_and:c (gt:c@2 @0 @1) (eqne @0 min_value))
```
to:
```
(for eqne (eq ne)
 (simplify
  (bit_and:c (gt:c@2 @0 @1) (eqne @3 uniform_integer_cst_p@2))
 (if (bitwise_equal_p (@0, @3)
      && min_value_p (TREE_TYPE (@0), uniform_integer_cst_p (@2))
```

Etc.

We could have min_value_p use uniform_integer_cst_p inside it instead of doing
it before hand.

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

end of thread, other threads:[~2023-11-02 21:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-02 20:53 [Bug tree-optimization/112356] New: `x == MIN & x > y` is not optimized to 0 if x was casted to signed from unsigned pinskia at gcc dot gnu.org
2023-11-02 20:53 ` [Bug tree-optimization/112356] " pinskia at gcc dot gnu.org
2023-11-02 21:00 ` 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).