https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94524
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- 4527 /* n rem d = n rem -d */ 4528 if (rem_flag && d < 0) 4529 { 4530 d = abs_d; 4531 op1 = gen_int_mode (abs_d, int_mode); 4532 } in expmed.c indeed canonicalizes this.