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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |115082

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> I have not looked if there is a pattern to do that or not (without the
> second use of captured+1.

There is not a pattern that handles:
```
bool f(int captured)
{
  return (((captured)+1)&1) == 0;
}
```
what does it is VRP.
VRP does it is by folding `zero_one_valued == 0` into `(bool)(zero_one_valued ^
1)` And then there are patterns to handle that (in some award way)

VRP does not change GIMPLE_COND here since == 0 is simplier than the extra xor.



Note `(((captured)+1)&1)` can be canonicalize as `1 & ~a` which is PR 115082.
and then `(1&~a) == 0` is not currently simplified into `a != 0`  though.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115082
[Bug 115082] Canonical form for `(a+oddCST)&1` or `1 & ~a`

Reply via email to