-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JIT: better addressing mode for floating point on arm64 #65468
Conversation
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsCloses #64819 float Test(float[] arr, int i) => arr[i]; codegen diff: G_M60861_IG01:
stp fp, lr, [sp,#-16]!
mov fp, sp
G_M60861_IG02:
ldr w0, [x1,#8]
cmp w2, w0
bhs G_M60861_IG04
- ubfiz x0, x2, #2, #32
- add x0, x0, #16
- ldr s0, [x1, x0]
+ add x0, x1, #16
+ ldr s0, [x0, w2, UXTW #2]
G_M60861_IG03:
ldp fp, lr, [sp],#16
ret lr
G_M60861_IG04:
bl CORINFO_HELP_RNGCHKFAIL
brk_windows #0
-; Total bytes of code: 48
+; Total bytes of code: 44
|
@kunalspathak PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Seems there are quite a few regressions. E.g. linux arm64 coreclr_tests. Can you double check?
|
I pushed one more change and it made diffs much better.
(we don't care about it on x64 because the whole thing can be contained) 2nd is usually better for ARM64 but there are cases where it's not, e.g: static double[] x;
static double[] y;
double foo(int i)
{
return x[i] + y[i];
} here we access two different arrays with the same index so we'd better do CSE for I propose we merge this as is (because all collections except tests are improved) and then think of a better way to address this problem, most likely it needs a special "Reassociate" phase. or special casing in CSE non floating-point addressing modes are also affected, I'll file an issue with more details. |
Sounds good to me. Can you share how does the regression looks like? |
Sure, here is both good and bad cases: static double[] x;
static double[] y;
static double Bad(int i)
=> x[i] + y[i]; // (ArrayRef + dataConstOffset) can not be CSE'd, only index is
static double Good(int i)
=> x[i] + x[i + 1]; // (ArrayRef + dataConstOffset) can be CSE'd, index is not Diff: https://www.diffchecker.com/voeWEctL Btw, other primitives are also affected |
You mean with this change other primitives are also affected? |
No, I mean other primitives already go the path "prefer CSE for 'ArrayRef + DataConstOffset'" - this PR basically aligns behavior between floats and other primitives |
Makes sense. |
Closes #64819
codegen diff:
Diffs