int f(int a, int b) { return a * (b / a); } This is equivalent to `return b - (b % a);`. This transformation is done by LLVM, but not by GCC.
Confirmed.
This appears to have been fixed as bug 96696 via the following commit: https://gcc.gnu.org/g:3dcd1334b4f522352b80814513fdca902fc2a207
This should make it to GCC 12 when it's released, so I'm closing it accordingly.