No integer exists for which there is remainder after division by 1.
Incidentally, this fold is only valid for D u> 1. (power-of-two is ok.)
While we could just bailout and let it constant-fold for scalars and
splat vectors, we *do* want to handle non-splat vectors where at least
one divisor happens to be 1.
We know that
- (X u% 1) == 0 can be constant-folded to 1,
- (X u% 1) != 0 can be constant-folded to 0,
Also, we know that
- X u<= -1 can be constant-folded to 1,
- X u> -1 can be constant-folded to 0,
https://godbolt.org/z/7jnZJX https://rise4fun.com/Alive/oF6p
We know will end up with the following:
(setule/setugt (rotr (mul N, P), K), Q)
Therefore, for given new DAG nodes and comparison predicates (ule/ugt),
we will still produce the correct answer if: Q is a all-ones constant;
and both P and K are *anything* other than undef, let's pick 0,
because there's no point in rotating, and because (X * 0) most
obviously "discards" of the value of X.