https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115366
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Summary|Missing optimzation: fold |Missing optimzation: fold |`return (bool)(((a / 8) * |`(bool)(a<< boolvalue)` to |4) << f)` to `return |`(bool)(a)` |(bool)(a / 8)` | Last reconfirmed| |2024-06-06 Severity|normal |enhancement Ever confirmed|0 |1 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- 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.