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

Kael Franco <kaelfandrew at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|tree-optimization           |target
           See Also|                            |https://github.com/llvm/llv
                   |                            |m-project/issues/218553
            Summary|Missed optimization of plus |Missed LLVM's or disjoint
                   |to or when x < CST          |detection for targets
           Keywords|easyhack                    |

--- Comment #2 from Kael Franco <kaelfandrew at gmail dot com> ---
More general testcase:

```
#define TYPE_PREC 32
#define TYPE unsigned _BitInt(TYPE_PREC)

TYPE
src_add (TYPE x, TYPE y)
{
  if ((x & y) != 0)
    __builtin_unreachable ();

  return (x + y);
}

TYPE
src_or (TYPE x, TYPE y)
{
  if ((x & y) != 0)
    __builtin_unreachable ();

  return (x | y);
}

TYPE
src_xor (TYPE x, TYPE y)
{
  if ((x & y) != 0)
    __builtin_unreachable ();

  return (x ^ y);
}
```

GCC should output (In assembly) the equivalent of return x (+,|,&,^) y.
LLVM's instruction or has disjoint flag that was added in
https://github.com/llvm/llvm-project/pull/72583.

Reply via email to