https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101541
--- Comment #11 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:0fc13e8c0e39c51e82deb93f324d9d86ad8d7460 commit r14-4889-g0fc13e8c0e39c51e82deb93f324d9d86ad8d7460 Author: Andrew Pinski <pins...@gmail.com> Date: Sun Oct 15 19:15:38 2023 +0000 Improve factor_out_conditional_operation for conversions and constants In the case of a NOP conversion (precisions of the 2 types are equal), factoring out the conversion can be done even if int_fits_type_p returns false and even when the conversion is defined by a statement inside the conditional. Since it is a NOP conversion there is no zero/sign extending happening which is why it is ok to be done here; we were trying to prevent an extra sign/zero extend from being moved away from definition which no-op conversions are not. Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: PR tree-optimization/104376 PR tree-optimization/101541 * tree-ssa-phiopt.cc (factor_out_conditional_operation): Allow nop conversions even if it is defined by a statement inside the conditional. gcc/testsuite/ChangeLog: PR tree-optimization/101541 * gcc.dg/tree-ssa/phi-opt-39.c: New test.