Uh oh!
There was an error while loading. Please reload this page.
JIT: better addressing mode for floating point on arm64 - #65468
Conversation
ghost
commented
Feb 16, 2022
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsCloses #64819 floatTest(float[]arr,inti)=>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
|
EgorBo
commented
Feb 16, 2022
@kunalspathak PTAL |
kunalspathak
commented
Feb 17, 2022
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: staticdouble[]x;staticdouble[]y;doublefoo(inti){returnx[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. |
kunalspathak
commented
Feb 17, 2022
Sounds good to me. Can you share how does the regression looks like? |
Sure, here is both good and bad cases: staticdouble[]x;staticdouble[]y;staticdoubleBad(inti)=>x[i]+y[i];// (ArrayRef + dataConstOffset) can not be CSE'd, only index isstaticdoubleGood(inti)=>x[i]+x[i+1];// (ArrayRef + dataConstOffset) can be CSE'd, index is notDiff: https://www.diffchecker.com/voeWEctL Btw, other primitives are also affected |
kunalspathak
commented
Feb 17, 2022
You mean with this change other primitives are also affected? |
EgorBo
commented
Feb 17, 2022
No, I mean other primitives already go the path "prefer CSE for 'ArrayRef + DataConstOffset'" - this PR basically aligns behavior between floats and other primitives |
kunalspathak
commented
Feb 17, 2022
Makes sense. |
Closes#64819
codegen diff:
Diffs