It would be nice if there was an easy way to automatically treat / by 2N as equivalent to right-shift by N (arithmetic if signed, logical if unsigned), * by 2N as equivalent to left-shift by N, % by 2N as bitwise and by 2N-1 (when unsigned). But only when such a specialized mul/div/mod can qualify (eg. math by constant power of two operand), and preferrably opt-in to prevent unwanted optimization from happening.
Then you'd be able to write x /= 16 instead of x >>= 4 or similar.
Potentially this sugar could also be extended to use more optimized instructions than just shifting, if applicable, too. eg. swap + bitwise and on the GB when dividing by 16.
It would be nice if there was an easy way to automatically treat
/
by 2N as equivalent to right-shift by N (arithmetic if signed, logical if unsigned),*
by 2N as equivalent to left-shift by N,%
by 2N as bitwise and by 2N-1 (when unsigned). But only when such a specialized mul/div/mod can qualify (eg. math by constant power of two operand), and preferrably opt-in to prevent unwanted optimization from happening.Then you'd be able to write
x /= 16
instead ofx >>= 4
or similar.Potentially this sugar could also be extended to use more optimized instructions than just shifting, if applicable, too. eg. swap + bitwise and on the GB when dividing by 16.