We could use knownbits on both operands for even more folds (and there are already tests in place for that), but this is enough to recover the example from:
https://github.com/llvm/llvm-project/issues/51934
(the tests are derived from the code in that example)
I am assuming no noticeable compile-time impact from this because udiv/urem are rare opcodes, but I could check that if there is concern.
Can't you just test if (KnownX.getMaxValue().ult(*C))?