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

Kael Franco <kaelfandrew at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kaelfandrew at gmail dot com

--- Comment #2 from Kael Franco <kaelfandrew at gmail dot com> ---
(In reply to Drea Pinski from comment #1)
> The missed optimization here is really just:
> ```
> bool fn1(unsigned short a, bool f) {
>     return a << f != 0; // equals to return a / 8;
> }
> ```
> is not optimized to:
> ```
> bool fn1(unsigned short a, bool f) {
>     return a != 0; // equals to return a / 8;
> }
> ```
> 
> Since `((int)a) << [0,1] != 0` is the same as `((int)a) != 0`.
> 
> After that, GCC already has the rest.

This is only true if a is not 0x8000. If a is 0x8000, then 0x8000 << f != 0
becomes f == 0
Similar to r15-6929-g903ab914dd48c3

Reply via email to