https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111260
--- Comment #12 from GCC 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:5fa27d9f8c4bec65887654e374146926d76690b0 commit r14-6562-g5fa27d9f8c4bec65887654e374146926d76690b0 Author: Andrew Pinski <quic_apin...@quicinc.com> Date: Tue Dec 12 21:55:50 2023 -0800 middle-end: Fix up constant handling in emit_conditional_move [PR111260] After r14-2667-gceae1400cf24f329393e96dd9720, we force a constant to a register if it is shared with one of the other operands. The problem is used the comparison mode for the register but that could be different from the operand mode. This causes some issues on some targets. To fix it, we need to make sure the mode of the comparison matches the mode of the other operands, before we can compare the constants (CONST_INT has no modes so compare_rtx returns true if they have the same value even if the usage is in a different mode). Bootstrapped and tested on both aarch64-linux-gnu and x86_64-linux. PR middle-end/111260 gcc/ChangeLog: * optabs.cc (emit_conditional_move): Change the modes to be equal before forcing the constant to a register. gcc/testsuite/ChangeLog: * gcc.c-torture/compile/condmove-1.c: New test. Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>