Open EgorBo opened 5 years ago
Btw, RyuJIT is able to optimize
X % C == 0
to X & (C-1) == 0
only for unsigned X (should work for signed types too).
@dotnet/jit-contrib
Partly addressed in https://github.com/dotnet/coreclr/pull/25744
Interesting, I don't remember seeing the x % 100 == 0
transform before. I guess it's a variation on magic division.
Interesting, I don't remember seeing the
x % 100 == 0
transform before. I guess it's a variation on magic division.
I have a demo for JIT: https://github.com/EgorBo/runtime-1/commit/705d3cb1d9bf2c5d2ead7487c1a6104e1a4d6bc8
it's a straight port of https://reviews.llvm.org/D65366
I was looking for opportunities to improve performance of
DateTime.UtcNow
and noticed that JIT doesn't use magic tricks/peephole optimizations to improve codegen for this:Currently generates (tier1):
And here is the difference between what GCC generates and RyuJIT:
See godbolt.
category:cq theme:basic-cq skill-level:expert cost:medium impact:medium