Repository navigation
ARM64: Optimize a % b operation #34937
Description
Activity
- addeduntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on Apr 14, 2020 Dotnet-GitSync-Bot commented
on Apr 14, 2020 CollaboratorMore actionsI couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label.
- addedarea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
on Apr 14, 2020 Jit currently always gives up on
%on Arm and always converts it toa - (a / b) * bin the morph phase, thus existing%(GT_MOD, GT_UMOD) optimizations in both morph and lowering don't work for it (happen later).Yes, I have already spoke to @sandreenko about it and reverted some of the changes he did in dotnet/coreclr#18206. With that it handles the 1st case (where
ais unsigned andbis power of 2). I need to handle other 2 cases yet.- added and removeduntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on Apr 20, 2020 - addedJitUntriagedCLR JIT issues needing additional triageCLR JIT issues needing additional triage
on Oct 28, 2020 - removedJitUntriagedCLR JIT issues needing additional triageCLR JIT issues needing additional triage
on Nov 25, 2020 Definitely, this will not happen in .NET 6.0.
Just noting that unlike #64591, this one is over integer types and should be safe. I'm not aware of any cases (off the top of my head) where the output could differ for
a * b + cwhen only handling integers.Its certainly possible, however, that there is some edge case I'm not remembering or with certain variants of the instruction (there are variants that multiply, widen or narrow, and then add/subtract for example and these may have some edge case behavior depending on how they are used and other surrounding optimizations).
We already fold
a * b + cintomaddon arm.Reacted by Kunal PathakClosing as we have finished the optimizations listed here.
- ghost locked as resolved and limited conversation to collaborators
on May 14, 2022
Optimize
a % boperation for ARM64 for following scenarios:ais unsigned int,bis power of 2.Today we generate something like this:
We can generate:
ais signed int,bis power of 2.Today we generate:
We can generate:
ais an int,bis a variable.Today we generate:
We can generate using
msub:Reference: https://godbolt.org/z/yxH8jZ
Reference: https://patchwork.kernel.org/patch/11126001/
category:cq
theme:optimization
skill-level:intermediate
cost:medium