https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109187
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Alexander Monakov <amona...@gcc.gnu.org>: https://gcc.gnu.org/g:fb046e69f0ed2d637ea715ae71ad50131f30cb2d commit r13-6907-gfb046e69f0ed2d637ea715ae71ad50131f30cb2d Author: Alexander Monakov <amona...@ispras.ru> Date: Tue Mar 28 16:00:37 2023 +0300 haifa-sched: fix autopref_rank_for_schedule comparator [PR109187] Do not attempt to use a plain subtraction for generating a three-way comparison result in autopref_rank_for_schedule qsort comparator, as offsets are not restricted and subtraction may overflow. Open-code a safe three-way comparison instead. gcc/ChangeLog: PR rtl-optimization/109187 * haifa-sched.cc (autopref_rank_for_schedule): Avoid use of overflowing subtraction in three-way comparison. gcc/testsuite/ChangeLog: PR rtl-optimization/109187 * gcc.dg/pr109187.c: New test.