https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120360
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:5f4e794fd3efb0e44a6b5afdead95033df69c41b commit r16-815-g5f4e794fd3efb0e44a6b5afdead95033df69c41b Author: Jakub Jelinek <ja...@redhat.com> Date: Thu May 22 09:09:48 2025 +0200 i386: Extend *cmp<mode>_minus_1 optimizations also to plus with CONST_INT [PR120360] As mentioned by Linus, we can't optimize comparison of otherwise unused result of plus with CONST_INT second operand, compared against zero. This can be done using just cmp instruction with negated constant and say js/jns/je/jne etc. conditional jumps (or setcc). We already have *cmp<mode>_minus_1 instruction which handles it when (as shown in foo in the testcase) the IL has MINUS rather than PLUS, but for constants except for the minimum value the canonical form is with PLUS. The following patch adds a new pattern and predicate to handle this. 2025-05-22 Jakub Jelinek <ja...@redhat.com> PR target/120360 * config/i386/predicates.md (x86_64_neg_const_int_operand): New predicate. * config/i386/i386.md (*cmp<mode>_plus_1): New pattern. * gcc.target/i386/pr120360.c: New test.