On 25/07/15 03:19, Segher Boessenkool wrote:
On Fri, Jul 24, 2015 at 09:09:39AM +0100, Kyrill Tkachov wrote:
This transformation folds (X % C) == N into
X & ((1 << (size - 1)) | (C - 1))) == N
for constants C and N where N is positive and C is a power of 2.
For N = 0 you can transform it to

        ((unsigned)X % C) == N

and for 0 < N < C you can transform it to

        X > 0 && ((unsigned)X % C) == N          (or X >= 0)

and for -C < N < 0 it is

        X < 0 && ((unsigned)X % C) == N + C      (or X <= 0)

and for other N it is

        0.

For N not a constant, well, do you really care?  :-)

(That second case might eventually fold to your original expression).

Yeah, these avoid the potentially expensive mask, but introduce more operations,
which I believe may not be desirable at this stage.
Unless these transformations are ok for match.pd I'll try to implement this 
transformation
at RTL expansion time.

Thanks,
Kyrill



Segher


Reply via email to