https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103228
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <pins...@gcc.gnu.org>: https://gcc.gnu.org/g:32221357007666124409ec3ee0d3a1cf263ebc9e commit r12-5358-g32221357007666124409ec3ee0d3a1cf263ebc9e Author: Andrew Pinski <apin...@marvell.com> Date: Mon Nov 15 09:31:20 2021 +0000 Fix PR tree-optimization/103228 and 103228: folding of (type) X op CST where type is a nop convert Currently we fold (type) X op CST into (type) (X op ((type-x) CST)) when the conversion widens but not when the conversion is a nop. For the same reason why we move the widening conversion (the possibility of removing an extra conversion), we should do the same if the conversion is a nop. Committed as approved with the comment change. PR tree-optimization/103228 PR tree-optimization/55177 gcc/ChangeLog: * match.pd ((type) X bitop CST): Also do this transformation for nop conversions. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr103228-1.c: New test. * gcc.dg/tree-ssa/pr55177-1.c: New test.