[Bug tree-optimization/112356] `x == MIN & x > y` is not optimized to 0 if x was casted to signed from unsigned

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Nov 2 21:00:26 GMT 2023


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.


More information about the Gcc-bugs mailing list