https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103220
--- Comment #4 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:74faa9834a9ad208e34f67b08c854c20b0fcfe92 commit r12-5430-g74faa9834a9ad208e34f67b08c854c20b0fcfe92 Author: Andrew Pinski <apin...@marvell.com> Date: Sat Nov 20 01:37:54 2021 +0000 Fix tree-optimization/103220: Another missing folding of (type) X op CST where type is a nop convert The problem here is that int_fits_type_p will return false if we just change the sign of things like -2 (or 254) so we should accept the case where we just change the sign (and not the precision) of the type. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR tree-optimization/103220 gcc/ChangeLog: * match.pd ((type) X bitop CST): Don't check if CST fits into the type if only the sign changes. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr103220-1.c: New test. * gcc.dg/tree-ssa/pr103220-2.c: New test. * gcc.dg/pr25530.c: Update test to check for 4294967294 in the case -2 is not matched.