https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103314
--- Comment #8 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:ea2954df43d4162af23a20c84f4c5485463977ac commit r12-5400-gea2954df43d4162af23a20c84f4c5485463977ac Author: Andrew Pinski <apin...@marvell.com> Date: Fri Nov 19 01:42:41 2021 +0000 Fix tree-optimization/103314 : Limit folding of (type) X op CST where type is a nop convert to gimple There is some re-association code in fold_binary which conflicts with this optimization due keeping around some "constants" which are not INTEGER_CST (1 << -1) so we end up in an infinite loop because of that. So we need to limit this case to GIMPLE level only. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR tree-optimization/103314 gcc/ChangeLog: * match.pd ((type) X op CST): Restrict the equal TYPE_PRECISION case to GIMPLE only. gcc/testsuite/ChangeLog: * gcc.c-torture/compile/pr103314-1.c: New test.