Transform icmp udiv into simpler instructions.
https://github.com/llvm/llvm-project/issues/55695.
Depends D156028.
More efficient solutions:
Unsigned division, unsigned > (godbolt, alive)
bool src(uint32_t x, uint32_t y, uint32_t z) { return x / y > z; } bool tgt(uint32_t x, uint32_t y, uint32_t z) { uint64_t zPlusOne = (uint64_t)(z) + 1; return x >= (uint64_t)y * zPlusOne; }
Unsigned division, unsigned >= (godbolt, alive)
bool src(uint32_t x, uint32_t y, uint32_t z) { return x / y >= z; } bool tgt(uint32_t x, uint32_t y, uint32_t z) { return x >= (uint64_t)y * z; }
Unsigned division, unsigned < (godbolt, alive)
bool src(uint32_t x, uint32_t y, uint32_t z) { return x / y < z; } bool tgt(uint32_t x, uint32_t y, uint32_t z) { return x < (uint64_t)y * z; }
Unsigned division, unsigned <= (godbolt, alive)
bool src(uint32_t x, uint32_t y, uint32_t z) { return x / y <= z; } bool tgt(uint32_t x, uint32_t y, uint32_t z) { uint64_t zPlusOne = (uint64_t)(z) + 1; return x < (uint64_t)y * zPlusOne; }
Unsigned division, == (godbolt, alive)
bool src(uint32_t x, uint32_t y, uint32_t z) { return x / y == z; } bool tgt(uint32_t x, uint32_t y, uint32_t z) { uint64_t y_multiply_z = (uint64_t)y * z; bool is_less = x < y_multiply_z; bool is_less_or_equal = x < y_multiply_z + y; return is_less_or_equal && !is_less; }
Unsigned division, != (godbolt, alive)
bool src(uint32_t x, uint32_t y, uint32_t z) { return x / y != z; } bool tgt(uint32_t x, uint32_t y, uint32_t z) { uint64_t y_multiply_z = (uint64_t)y * z; bool is_less = x < y_multiply_z; bool is_greater = x >= y_multiply_z + y; return is_greater || is_less; }
!isSigned?