https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82853

Wilco <wdijkstr at arm dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wdijkstr at arm dot com

--- Comment #23 from Wilco <wdijkstr at arm dot com> ---
(In reply to Jakub Jelinek from comment #22)
> So, while it isn't correct to replace x % 3U == 1 by (x - 1) % 3U == 0,
> because
> for x == 0 the test will yield a different value, as 0xffffffffU % 3U is 0
> and
> 0 % 3U is also 0, x % 3U == 1 is equivalent to (x - 1) * 0xaaaaaaabU <=
> 0x55555554U, but x % 3U == 0 is equivalent to x * 0xaaaaaaabU <= 0x55555555U.
> Now to see if something useful can be used also for the even divisors.

Yes for this case it is safe to do (x - 1) * 0xaaaaaaab < 0x55555555, but you
can also do x * 0xaaaaaaab >= 0xaaaaaaab which is even simpler. Basically (x %
C) == N is simpler for 2 values of N.

Reply via email to