-
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
ARM64: Avoid LEA for volatile IND #64354
Conversation
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsFollow up to #62895 volatile int f1;
volatile int f2;
void Test()
{
f1 = 1;
f2 = 1;
} Codgen diff: ; Method Runtime:Test():this
G_M53852_IG01: ;; offset=0000H
A9BF7BFD stp fp, lr, [sp,#-16]!
910003FD mov fp, sp
;; bbWeight=1 PerfScore 1.50
G_M53852_IG02: ;; offset=0008H
- 52800021 mov w1, #1
- D5033BBF dmb ish
- B9000801 str w1, [x0,#8]
- D5033BBF dmb ish
- B9000C01 str w1, [x0,#12]
- ;; bbWeight=1 PerfScore 22.50
+ 91002001 add x1, x0, #8
+ 52800022 mov w2, #1
+ 889FFC22 stlr w2, [x1]
+ 91003000 add x0, x0, #12
+ 889FFC02 stlr w2, [x0]
+ ;; bbWeight=1 PerfScore 3.50
G_M53852_IG03: ;; offset=001CH
A8C17BFD ldp fp, lr, [sp],#16
D65F03C0 ret lr
;; bbWeight=1 PerfScore 2.00
; Total bytes of code: 36 Same byte size, but better PerfScore (no memory barrier)
|
resulting assembly looks correct and better than before |
@dotnet/jit-contrib PTAL There are some size regressions (https://dev.azure.com/dnceng/public/_build/results?buildId=1575482&view=ms.vss-build-web.run-extensions-tab) due to additional instructions to prepare addresses instead of addressing modes, but PerfScore diffs are much better, e.g.
NOTE x64/x86 diffs are unrelated (not reproduceable locally) - spmi job picked a wrong baseline jit for them it seems |
It picks the same baseline for x64/x86/arm/arm64...so all the diffs are related to that baseline. The question is why it picked wrong baseline, perhaps we didn't catch up or something in jitrollingbuild? @BruceForstall - any idea?
I see that arm asmdiffs timesout which we are seeing more recently. I would probably rebase and double check with official baseline to make sure there is nothing suspicious. |
…-addrmode-volatile
Yeah I noticed it in my other PR today, some superpmi job silently fails and then displays some previous diffs or something like that. Rebased. |
Also that might explain the huge diffs followed by timeouts that many of us are seeing. |
Co-authored-by: Kunal Pathak <Kunal.Pathak@microsoft.com>
It seems that the snippet add x1, x0, #8
mov w2, #1
stlr w2, [x1] can be optimized even further on targets supporting ARMv8.4 mov w2, #1
stlur w2, [x0, #8] @EgorBo As a general thought, I wonder if in void Test()
{
f1 = 1;
f2 = 1;
} the first write needs to be store-release? Shouldn't the following be sufficient?
|
Good idea! Will file an issue, not sure even my M1 supports it 😄
I am not sure why I used two variables in that snippet, the issue reproduces even with a single. |
@kunalspathak no irrelevant diffs after rebase: https://dev.azure.com/dnceng/public/_build/results?buildId=1576187&view=ms.vss-build-web.run-extensions-tab |
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. Thanks!
The jitrollingbuild pipeline is set to build every time the JIT changes, and not batch changes:
However, it appears that AzDO doesn't kick off the build immediately; I noticed a delay of about 10 minutes for this particular change. In a few previous cases for JIT changes, there were also delays before the AzDO job kicked off, and in those cases, another change was merged before the kickoff, and AzDO built that change, not the JIT change that kicked off the job. Because of this, when we upload the JIT to Azure Storage, we use a git hash of a non-JIT change, and when superpmi.py looks for a baseline JIT, it doesn't find the hash of the JIT that should have been built. Summary: there is an assumption that the pipeline builds every JIT change at the git hash of the JIT change. That doesn't appear to be the case with AzDO. I'm not sure if there's a config to force that to happen. E.g., what if 2 JIT changes were merged at almost exactly the same time? AzDO should build both of them, but does it? Possibly we could change the jitrollingbuild.py upload script to walk back the |
Added #64392 |
Follow up to #62895
e.g.:
Codgen diff:
Same byte size, but better PerfScore (no memory barrier)