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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|tree-optimization           |middle-end

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So what is happening is there is a missed Canonicalization happening here at
the gimple level and only at the RTL level we decide to expand `(num & 7LL) ==
7LL` as `((~num) & 7) == 0` (for x86_64). For aarch64 we expand still as `(num
&7) == 7`.

So we should pick one for the gimple level and then expand it and also actually
do better CSE of `~num` for the RTL level.

The other thing GCC should do better at is handle:
```
bool checko(long long num) {
    if((num & 7LL) == 7LL)
        return true;
    if((num & 22LL) == 22LL)
        return true;
    return false;
}
```
Into:
```
        and     x1, x0, 7
        mov     x2, 22
        cmp     x1, 7
        and     x0, x0, x2
        ccmp    x0, x2, 4, ne
        cset    w0, eq
```

For aarch64.
I have an idea there ...

Reply via email to