https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102245
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Roger Sayle <sa...@gcc.gnu.org>: https://gcc.gnu.org/g:2578a3870ef849dc77e98796600181b64ae4fd61 commit r12-3623-g2578a3870ef849dc77e98796600181b64ae4fd61 Author: Roger Sayle <ro...@nextmovesoftware.com> Date: Fri Sep 17 15:57:34 2021 +0100 PR c/102245: Disable sign-changing optimization for shifts by zero. Respecting Jakub's suggestion that it may be better to warn-on-valid for "if (x << 0)" as the author might have intended "if (x < 0)" [which will also warn when x is _Bool], the simplest way to resolve this regression is to disable the recently added fold transformation for shifts by zero; these will be optimized later (elsewhere). Guarding against integer_zerop is the simplest of three alternatives; the second being to only apply this transformation to GIMPLE and not GENERIC, and the third (potentially) being to explicitly handle shifts by zero here, with an (if cond then else), optimizing the expression to a convert, but awkwardly duplicating a more general transformation earlier in match.pd's shift simplifications. 2021-09-17 Roger Sayle <ro...@nextmovesoftware.com> gcc/ChangeLog PR c/102245 * match.pd (shift optimizations): Disable recent sign-changing optimization for shifts by zero, these will be folded later. gcc/testsuite/ChangeLog PR c/102245 * gcc.dg/Wint-in-bool-context-4.c: New test case.