https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94899
--- Comment #5 from CVS 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:ab981aab92cbc71918fbaadcf6fa64bdb2b69be7 commit r13-1187-gab981aab92cbc71918fbaadcf6fa64bdb2b69be7 Author: Arjun Shankar <ar...@redhat.com> Date: Tue Jun 21 12:12:11 2022 +0200 match.pd: Remove "+ 0x80000000" in int comparisons [PR94899] Expressions of the form "X + CST < Y + CST" where: * CST is an unsigned integer constant with only the MSB set, and * X and Y's types have integer conversion ranks <= CST's can be simplified to "(signed) X < (signed) Y". This is because, assuming a 32-bit signed numbers, (unsigned) INT_MIN + 0x80000000 is 0, and (unsigned) INT_MAX + 0x80000000 is UINT_MAX. i.e. the result increases monotonically with signed input. This means: ((signed) X < (signed) Y) iff (X + 0x80000000 < Y + 0x80000000) gcc/ PR tree-optimization/94899 * match.pd (X + C < Y + C -> (signed) X < (signed) Y, if C is 0x80000000): New simplification. gcc/testsuite/ * gcc.dg/pr94899.c: New test.