here's the GCC peephole rule: https://github.com/gcc-mirror/gcc/blob/427386042f056a2910882bf0c632b4db68c52bbb/gcc/match.pd#L6920-L6946
"For integral types with undefined overflow fold x * C1 == C2 into x == C2 / C1 or false. If overflow wraps and C1 is odd, simplify to x == C2 / C1 in the ring Z / 2^n Z."