https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96697
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- For signed x and y, x % y == x % -y, x % y has the sign of x. So for x in non-negative you can use x % y < abs(y) and generally -abs(y) < x % y < abs(y)