ARM64 - Optimizing a % b operations#65535
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsAddressing this issue: #34937 Description There are various ways to optimize Example: Acceptance Criteria
|
|
Shouldn't we just remove early expansion of UMOD/MOD for arm64 from morph and use the shared (with x86) impl in lower instead? |
|
@EgorBo are you referring to |
yeah, and just move One potential problem with this approach that it might produce regressions where |
|
It makes sense that we should do it there so the earlier phases don't screw it up. |
|
I did some work to see if I could move the existing mod optimizations to lowering, but it might be a bit much for what the PR is trying to accomplish. |
@EgorBo, I would've thought it was better to do it early in morph so other things can more easily take advantage of the optimization (we don't optimize around |
I agree. |
cc @kunalspathak @tannergooding I personally think it's not, for any non-leaf X in instead of just: E.g. it makes it non-hoistable for ARM64, e.g. see this: |
|
@EgorBo, I was referring specifically to the It should be a clear improvement to recognize and replace |
I'm fine with doing |
|
@kunalspathak @echesakovMSFT This is ready. Will try to restart CI. |
kunalspathak
left a comment
There was a problem hiding this comment.
LGTM with nice diffs.
* Initial work for ARM64 mod optimization * Updated comment * Updated comment * Updated comment * Fixing build * Remove uneeded var * Use '%' morph logic for both x64/arm64 * Adding back in divisor check for x64 * Formatting * Update comments * Update comments * Fixing * Updated comment * Updated comment * Tweaking x64 transformation logic for the mod opt * Tweaking x64 transformation logic for the mod opt * Using IntCon * Fixed build * Minor tweak * Fixing x64 diffs * Removing flag set * Feedback * Fixing build * Feedback * Fixing tests * Fixing tests * Fixing tests * Formatting * Fixing tests * Feedback * Fixing build

Addressing part of this issue: #34937
Description
There are various ways to optimize
%for integers on ARM64.a % bcan be transformed intoa & (b - 1)if they are unsigned integers andbis a constant with the power of 2.Acceptance Criteria
Add Tests(asmdiffs cover this)