Skip to content

arm64: Prefer comparand register for CASAL results - #138203

Open
jonathandavies-arm wants to merge 1 commit into
dotnet:mainfrom
jonathandavies-arm:upstream/opt/arm64-casal-result-register
Open

jonathandavies-arm wants to merge 1 commit into
dotnet:mainfrom
jonathandavies-arm:upstream/opt/arm64-casal-result-register

Conversation

@jonathandavies-arm

Copy link
Copy Markdown
Contributor

CASAL overwrites its comparand register with the old memory value. Prefer that register for the compare-exchange result, allowing the allocator to avoid an extra register-to-register copy when the comparand dies at the operation.

Add a disassembly test that keeps the result live across a call and checks that the comparand is materialized directly in the result register.

Related to #136694.

Validation

  • Checked ARM64 runtime, JIT, and CoreLib builds: zero warnings or errors.
  • CASAL execution and disassembly checks passed; execution also passed with ARM64 atomics disabled.
  • ARM64 SuperPMI asmdiffs against main at a9ffa6f8b33c: 3,141,981 contexts across 12 collections, with no missing or failing compiles. There were 375 contexts with assembly differences; 277 became smaller and none grew. Total generated code decreased by 2,264 bytes. These are compilation-context counts, including overlapping collections, rather than unique methods.

SuperPMI code-size results

Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
aspnet2.run.linux.arm64.checked.mch 22,422,744 -144 -2.07%
benchmarks.run.linux.arm64.checked.mch 36,128,560 -60 -1.41%
benchmarks.run_pgo.linux.arm64.checked.mch 42,029,200 -76 -3.31%
benchmarks.run_pgo_optrepeat.linux.arm64.checked.mch 36,134,896 -60 -1.41%
coreclr_tests.run.linux.arm64.checked.mch 553,209,668 -340 -2.43%
libraries.crossgen2.linux.arm64.checked.mch 63,404,992 -44 -1.80%
libraries.pmi.linux.arm64.checked.mch 80,584,024 -168 -1.90%
libraries_tests.run.linux.arm64.Release.mch 533,039,552 -956 -0.71%
libraries_tests_no_tiered_compilation.run.linux.arm64.Release.mch 198,948,068 -356 -1.19%
realworld.run.linux.arm64.checked.mch 14,565,168 -60 -1.61%

The Aspire and NativeAOT smoke-test collections had no assembly differences. PerfScore is the JIT's static estimate, not a measured application speedup.

CASAL overwrites its comparand register with the old memory value.
When the comparand dies at the compare-exchange, prefer its register
for the result to avoid an extra register-to-register copy.

Add a disassembly test that keeps the result live across a call and
checks that the comparand is materialized directly in the result register.
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Nov 24, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 24, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 7 pipeline(s).
8 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@jonathandavies-arm

Copy link
Copy Markdown
Contributor Author

Result tables are complete. Examples are limited to one per collection; detailed method rankings are omitted to fit the GitHub comment limit.

Diffs are based on 3,141,981 contexts (1,189,127 MinOpts, 1,952,854 FullOpts).

Overall (-2,264 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
aspnet2.run.linux.arm64.checked.mch 22,422,744 -144 -2.07%
benchmarks.run.linux.arm64.checked.mch 36,128,560 -60 -1.41%
benchmarks.run_pgo.linux.arm64.checked.mch 42,029,200 -76 -3.31%
benchmarks.run_pgo_optrepeat.linux.arm64.checked.mch 36,134,896 -60 -1.41%
coreclr_tests.run.linux.arm64.checked.mch 553,209,668 -340 -2.43%
libraries.crossgen2.linux.arm64.checked.mch 63,404,992 -44 -1.80%
libraries.pmi.linux.arm64.checked.mch 80,584,024 -168 -1.90%
libraries_tests.run.linux.arm64.Release.mch 533,039,552 -956 -0.71%
libraries_tests_no_tiered_compilation.run.linux.arm64.Release.mch 198,948,068 -356 -1.19%
realworld.run.linux.arm64.checked.mch 14,565,168 -60 -1.61%
FullOpts (-2,264 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
aspnet2.run.linux.arm64.checked.mch 15,612,324 -144 -2.07%
benchmarks.run.linux.arm64.checked.mch 35,792,772 -60 -1.41%
benchmarks.run_pgo.linux.arm64.checked.mch 16,779,964 -76 -3.31%
benchmarks.run_pgo_optrepeat.linux.arm64.checked.mch 35,799,108 -60 -1.41%
coreclr_tests.run.linux.arm64.checked.mch 184,910,048 -340 -2.43%
libraries.crossgen2.linux.arm64.checked.mch 63,402,588 -44 -1.80%
libraries.pmi.linux.arm64.checked.mch 80,462,028 -168 -1.90%
libraries_tests.run.linux.arm64.Release.mch 268,771,984 -956 -0.71%
libraries_tests_no_tiered_compilation.run.linux.arm64.Release.mch 183,824,372 -356 -1.19%
realworld.run.linux.arm64.checked.mch 14,188,828 -60 -1.61%
Example diffs
aspnet2.run.linux.arm64.checked.mch
-4 (-3.03%) : 363.dasm - System.Net.Sockets.SocketAsyncEventArgs:StartConfiguring():this (Instrumented Tier1)
@@ -25,8 +25,7 @@ G_M4026_IG02:        ; bbWeight=1, gcrefRegs=80000 {x19}, byrefRegs=0000 {}, byr
             add     x0, x19, #172
             ; byrRegs +[x0]
             movn    w1, #0
-            mov     w2, wzr
-            mov     w20, w2
+            mov     w20, wzr
             casal   w20, w1, [x0]
             cbnz    w20, G_M4026_IG04
             movz    x0, #0xD1FFAB1E
@@ -35,7 +34,7 @@ G_M4026_IG02:        ; bbWeight=1, gcrefRegs=80000 {x19}, byrefRegs=0000 {}, byr
             movk    x0, #0xD1FFAB1E LSL #32
             bl      CORINFO_HELP_COUNTPROFILE32
             ; gcrRegs -[x19]
-						;; size=40 bbWeight=1 PerfScore 8.50
+						;; size=36 bbWeight=1 PerfScore 8.00
 G_M4026_IG03:        ; bbWeight=1, epilog, nogc, extend
             ldp     x19, x20, [sp, #0x10]
             ldp     fp, lr, [sp], #0x20
@@ -63,7 +62,7 @@ G_M4026_IG04:        ; bbWeight=0, gcVars=0000000000000000 {}, gcrefRegs=80000 {
             brk     #0
 						;; size=64 bbWeight=0 PerfScore 0.00
 
-; Total bytes of code 132, prolog size 12, PerfScore 14.50, instruction count 33, allocated bytes for code 132 (MethodHash=474bf045) for method System.Net.Sockets.SocketAsyncEventArgs:StartConfiguring():this (Instrumented Tier1)
+; Total bytes of code 128, prolog size 12, PerfScore 14.00, instruction count 32, allocated bytes for code 128 (MethodHash=474bf045) for method System.Net.Sockets.SocketAsyncEventArgs:StartConfiguring():this (Instrumented Tier1)
 ; ============================================================
 
 Unwind Info:
@@ -74,7 +73,7 @@ Unwind Info:
   E bit             : 0
   X bit             : 0
   Vers              : 0
-  Function Length   : 33 (0x00021) Actual length = 132 (0x000084)
+  Function Length   : 32 (0x00020) Actual length = 128 (0x000080)
   ---- Epilog scopes ----
   ---- Scope 0
   Epilog Start Offset        : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
benchmarks.run.linux.arm64.checked.mch
-4 (-0.39%) : 42357.dasm - System.Net.Sockets.Socket:SendToAsync(System.Net.Sockets.SocketAsyncEventArgs,System.Threading.CancellationToken):bool:this (FullOpts)
@@ -348,8 +348,7 @@ G_M25614_IG19:        ; bbWeight=1, gcrefRegs=100000 {x20}, byrefRegs=0000 {}, b
             add     x14, x19, #172
             ; byrRegs +[x14]
             mov     w15, #1
-            mov     w12, wzr
-            mov     w1, w12
+            mov     w1, wzr
             casal   w1, w15, [x14]
             cbnz    w1, G_M25614_IG33
             mov     w14, #9
@@ -364,7 +363,7 @@ G_M25614_IG19:        ; bbWeight=1, gcrefRegs=100000 {x20}, byrefRegs=0000 {}, b
             ; byrRegs -[x14]
             ldrb    w1, [x19, #0xBA]
             cbz     w1, G_M25614_IG21
-						;; size=56 bbWeight=1 PerfScore 16.50
+						;; size=52 bbWeight=1 PerfScore 16.00
 G_M25614_IG20:        ; bbWeight=0.50, gcrefRegs=180000 {x19 x20}, byrefRegs=0000 {}, byref
             movz    x1, #0xD1FFAB1E      // code for System.Threading.ExecutionContext:Capture():System.Threading.ExecutionContext
             movk    x1, #0xD1FFAB1E LSL #16
@@ -588,7 +587,7 @@ G_M25614_IG35:        ; bbWeight=0, gcVars=0000000010000003 {V00 V01 V05}, gcref
             brk     #0
 						;; size=52 bbWeight=0 PerfScore 0.00
 
-; Total bytes of code 1036, prolog size 32, PerfScore 145.00, instruction count 259, allocated bytes for code 1036 (MethodHash=94059bf1) for method System.Net.Sockets.Socket:SendToAsync(System.Net.Sockets.SocketAsyncEventArgs,System.Threading.CancellationToken):bool:this (FullOpts)
+; Total bytes of code 1032, prolog size 32, PerfScore 144.50, instruction count 258, allocated bytes for code 1032 (MethodHash=94059bf1) for method System.Net.Sockets.Socket:SendToAsync(System.Net.Sockets.SocketAsyncEventArgs,System.Threading.CancellationToken):bool:this (FullOpts)
 ; ============================================================
 
 Unwind Info:
@@ -599,7 +598,7 @@ Unwind Info:
   E bit             : 0
   X bit             : 0
   Vers              : 0
-  Function Length   : 245 (0x000f5) Actual length = 980 (0x0003d4)
+  Function Length   : 244 (0x000f4) Actual length = 976 (0x0003d0)
   ---- Epilog scopes ----
   ---- Scope 0
   Epilog Start Offset        : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
benchmarks.run_pgo.linux.arm64.checked.mch
-4 (-0.27%) : 24654.dasm - System.Net.Sockets.Socket:SendAsync(System.Net.Sockets.SocketAsyncEventArgs,System.Threading.CancellationToken):bool:this (Tier1)
@@ -195,8 +195,7 @@ G_M50197_IG02:        ; bbWeight=1, gcVars=0000000000080001 {V01 V97}, gcrefRegs
             add     x14, x19, #172
             ; byrRegs +[x14]
             mov     w15, #1
-            mov     w12, wzr
-            mov     w1, w12
+            mov     w1, wzr
             casal   w1, w15, [x14]
             cbnz    w1, G_M50197_IG32
             mov     w14, #7
@@ -211,7 +210,7 @@ G_M50197_IG02:        ; bbWeight=1, gcVars=0000000000080001 {V01 V97}, gcrefRegs
             ; byrRegs -[x14]
             ldrb    w0, [x19, #0xBA]
             cbnz    w0, G_M50197_IG33
-						;; size=64 bbWeight=1 PerfScore 18.50
+						;; size=60 bbWeight=1 PerfScore 18.00
 G_M50197_IG03:        ; bbWeight=1, gcrefRegs=180000 {x19 x20}, byrefRegs=0000 {}, byref, isz
             ldr     x20, [x20, #0x08]
             str     xzr, [x19, #0xB0]
@@ -786,7 +785,7 @@ G_M50197_IG35:        ; bbWeight=0.00, gcVars=0000000000000001 {V01}, gcrefRegs=
             brk     #0
 						;; size=32 bbWeight=0.00 PerfScore 0.00
 
-; Total bytes of code 1496, prolog size 44, PerfScore 143.11, instruction count 374, allocated bytes for code 1496 (MethodHash=93cf3bea) for method System.Net.Sockets.Socket:SendAsync(System.Net.Sockets.SocketAsyncEventArgs,System.Threading.CancellationToken):bool:this (Tier1)
+; Total bytes of code 1492, prolog size 44, PerfScore 142.61, instruction count 373, allocated bytes for code 1492 (MethodHash=93cf3bea) for method System.Net.Sockets.Socket:SendAsync(System.Net.Sockets.SocketAsyncEventArgs,System.Threading.CancellationToken):bool:this (Tier1)
 ; ============================================================
 
 Unwind Info:
@@ -797,7 +796,7 @@ Unwind Info:
   E bit             : 0
   X bit             : 0
   Vers              : 0
-  Function Length   : 364 (0x0016c) Actual length = 1456 (0x0005b0)
+  Function Length   : 363 (0x0016b) Actual length = 1452 (0x0005ac)
   ---- Epilog scopes ----
   ---- Scope 0
   Epilog Start Offset        : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
benchmarks.run_pgo_optrepeat.linux.arm64.checked.mch
-4 (-0.39%) : 41565.dasm - System.Net.Sockets.Socket:SendToAsync(System.Net.Sockets.SocketAsyncEventArgs,System.Threading.CancellationToken):bool:this (FullOpts)
@@ -348,8 +348,7 @@ G_M25614_IG19:        ; bbWeight=1, gcrefRegs=100000 {x20}, byrefRegs=0000 {}, b
             add     x14, x19, #172
             ; byrRegs +[x14]
             mov     w15, #1
-            mov     w12, wzr
-            mov     w1, w12
+            mov     w1, wzr
             casal   w1, w15, [x14]
             cbnz    w1, G_M25614_IG33
             mov     w14, #9
@@ -364,7 +363,7 @@ G_M25614_IG19:        ; bbWeight=1, gcrefRegs=100000 {x20}, byrefRegs=0000 {}, b
             ; byrRegs -[x14]
             ldrb    w1, [x19, #0xBA]
             cbz     w1, G_M25614_IG21
-						;; size=56 bbWeight=1 PerfScore 16.50
+						;; size=52 bbWeight=1 PerfScore 16.00
 G_M25614_IG20:        ; bbWeight=0.50, gcrefRegs=180000 {x19 x20}, byrefRegs=0000 {}, byref
             movz    x1, #0xD1FFAB1E      // code for System.Threading.ExecutionContext:Capture():System.Threading.ExecutionContext
             movk    x1, #0xD1FFAB1E LSL #16
@@ -588,7 +587,7 @@ G_M25614_IG35:        ; bbWeight=0, gcVars=0000000010000003 {V00 V01 V05}, gcref
             brk     #0
 						;; size=52 bbWeight=0 PerfScore 0.00
 
-; Total bytes of code 1036, prolog size 32, PerfScore 145.00, instruction count 259, allocated bytes for code 1036 (MethodHash=94059bf1) for method System.Net.Sockets.Socket:SendToAsync(System.Net.Sockets.SocketAsyncEventArgs,System.Threading.CancellationToken):bool:this (FullOpts)
+; Total bytes of code 1032, prolog size 32, PerfScore 144.50, instruction count 258, allocated bytes for code 1032 (MethodHash=94059bf1) for method System.Net.Sockets.Socket:SendToAsync(System.Net.Sockets.SocketAsyncEventArgs,System.Threading.CancellationToken):bool:this (FullOpts)
 ; ============================================================
 
 Unwind Info:
@@ -599,7 +598,7 @@ Unwind Info:
   E bit             : 0
   X bit             : 0
   Vers              : 0
-  Function Length   : 245 (0x000f5) Actual length = 980 (0x0003d4)
+  Function Length   : 244 (0x000f4) Actual length = 976 (0x0003d0)
   ---- Epilog scopes ----
   ---- Scope 0
   Epilog Start Offset        : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
coreclr_tests.run.linux.arm64.checked.mch
-4 (-1.35%) : 539799.dasm - System.Net.Sockets.SocketAsyncEventArgs:SetBuffer(System.Memory`1[byte]):this (FullOpts)
@@ -33,11 +33,10 @@ G_M50338_IG02:        ; bbWeight=1, gcVars=0000000000000001 {V00}, gcrefRegs=000
             add     x14, x0, #172
             ; byrRegs +[x14]
             movn    w15, #0
-            mov     w12, wzr
-            mov     w1, w12
+            mov     w1, wzr
             casal   w1, w15, [x14]
             cbnz    w1, G_M50338_IG10
-						;; size=24 bbWeight=1 PerfScore 6.00
+						;; size=20 bbWeight=1 PerfScore 5.50
 G_M50338_IG03:        ; bbWeight=1, gcrefRegs=0001 {x0}, byrefRegs=0000 {}, byref, isz
             ; byrRegs -[x14]
             lsr     x1, x2, #32
@@ -158,7 +157,7 @@ G_M50338_IG13:        ; bbWeight=0, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
             ret     lr
 						;; size=8 bbWeight=0 PerfScore 0.00
 
-; Total bytes of code 296, prolog size 20, PerfScore 35.75, instruction count 74, allocated bytes for code 296 (MethodHash=8e8c3b5d) for method System.Net.Sockets.SocketAsyncEventArgs:SetBuffer(System.Memory`1[byte]):this (FullOpts)
+; Total bytes of code 292, prolog size 20, PerfScore 35.25, instruction count 73, allocated bytes for code 292 (MethodHash=8e8c3b5d) for method System.Net.Sockets.SocketAsyncEventArgs:SetBuffer(System.Memory`1[byte]):this (FullOpts)
 ; ============================================================
 
 Unwind Info:
@@ -169,7 +168,7 @@ Unwind Info:
   E bit             : 0
   X bit             : 0
   Vers              : 0
-  Function Length   : 61 (0x0003d) Actual length = 244 (0x0000f4)
+  Function Length   : 60 (0x0003c) Actual length = 240 (0x0000f0)
   ---- Epilog scopes ----
   ---- Scope 0
   Epilog Start Offset        : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
libraries.crossgen2.linux.arm64.checked.mch
-4 (-2.08%) : 221879.dasm - System.Diagnostics.Process:get_BootTime():System.DateTime (FullOpts)
@@ -55,8 +55,7 @@ G_M32673_IG04:        ; bbWeight=0.50, gcrefRegs=0000 {}, byrefRegs=0000 {}, byr
             ; byrRegs +[x19]
             add     x0, x19, #8
             ; byrRegs +[x0]
-            mov     x1, xzr
-            mov     x19, x1
+            mov     x19, xzr
             ; byrRegs -[x19]
             casal   x19, x20, [x0]
             adrp    x0, [HIGH RELOC #0xD1FFAB1E]
@@ -64,7 +63,7 @@ G_M32673_IG04:        ; bbWeight=0.50, gcrefRegs=0000 {}, byrefRegs=0000 {}, byr
             ldr     x0, [x0, [LOW RELOC #0xD1FFAB1E]]
             ldr     w0, [x0]
             cbnz    w0, G_M32673_IG08
-						;; size=44 bbWeight=0.50 PerfScore 7.75
+						;; size=40 bbWeight=0.50 PerfScore 7.50
 G_M32673_IG05:        ; bbWeight=0.50, gcVars=0000000000000000 {}, gcrefRegs=0000 {}, byrefRegs=0000 {}, gcvars, byref
             ; GC ptr vars -{V06}
             cmp     x19, #0
@@ -92,7 +91,7 @@ G_M32673_IG08:        ; bbWeight=0, gcVars=0000000000000000 {}, gcrefRegs=0000 {
             b       G_M32673_IG05
 						;; size=16 bbWeight=0 PerfScore 0.00
 
-; Total bytes of code 192, prolog size 12, PerfScore 38.50, instruction count 48, allocated bytes for code 192 (MethodHash=d439805e) for method System.Diagnostics.Process:get_BootTime():System.DateTime (FullOpts)
+; Total bytes of code 188, prolog size 12, PerfScore 38.25, instruction count 47, allocated bytes for code 188 (MethodHash=d439805e) for method System.Diagnostics.Process:get_BootTime():System.DateTime (FullOpts)
 ; ============================================================
 
 Unwind Info:
@@ -103,7 +102,7 @@ Unwind Info:
   E bit             : 0
   X bit             : 0
   Vers              : 0
-  Function Length   : 48 (0x00030) Actual length = 192 (0x0000c0)
+  Function Length   : 47 (0x0002f) Actual length = 188 (0x0000bc)
   ---- Epilog scopes ----
   ---- Scope 0
   Epilog Start Offset        : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
libraries.pmi.linux.arm64.checked.mch
-4 (-0.31%) : 258659.dasm - System.Net.Sockets.Socket:SendToAsync(System.Net.Sockets.SocketAsyncEventArgs,System.Threading.CancellationToken):bool:this (FullOpts)
@@ -353,8 +353,7 @@ G_M25614_IG22:        ; bbWeight=1, gcrefRegs=100000 {x20}, byrefRegs=0000 {}, b
             add     x14, x19, #172
             ; byrRegs +[x14]
             mov     w15, #1
-            mov     w12, wzr
-            mov     w1, w12
+            mov     w1, wzr
             casal   w1, w15, [x14]
             cbnz    w1, G_M25614_IG43
             mov     w14, #9
@@ -369,7 +368,7 @@ G_M25614_IG22:        ; bbWeight=1, gcrefRegs=100000 {x20}, byrefRegs=0000 {}, b
             ; byrRegs -[x14]
             ldrb    w1, [x19, #0xBA]
             cbz     w1, G_M25614_IG24
-						;; size=56 bbWeight=1 PerfScore 16.50
+						;; size=52 bbWeight=1 PerfScore 16.00
 G_M25614_IG23:        ; bbWeight=0.50, gcrefRegs=180000 {x19 x20}, byrefRegs=0000 {}, byref
             movz    x1, #0xD1FFAB1E      // code for System.Threading.ExecutionContext:Capture():System.Threading.ExecutionContext
             movk    x1, #0xD1FFAB1E LSL #16
@@ -690,7 +689,7 @@ G_M25614_IG46:        ; bbWeight=0, gcVars=0000000004000003 {V00 V01 V05}, gcref
             brk     #0
 						;; size=52 bbWeight=0 PerfScore 0.00
 
-; Total bytes of code 1280, prolog size 36, PerfScore 152.72, instruction count 320, allocated bytes for code 1280 (MethodHash=94059bf1) for method System.Net.Sockets.Socket:SendToAsync(System.Net.Sockets.SocketAsyncEventArgs,System.Threading.CancellationToken):bool:this (FullOpts)
+; Total bytes of code 1276, prolog size 36, PerfScore 152.22, instruction count 319, allocated bytes for code 1276 (MethodHash=94059bf1) for method System.Net.Sockets.Socket:SendToAsync(System.Net.Sockets.SocketAsyncEventArgs,System.Threading.CancellationToken):bool:this (FullOpts)
 ; ============================================================
 
 Unwind Info:
@@ -701,7 +700,7 @@ Unwind Info:
   E bit             : 0
   X bit             : 0
   Vers              : 0
-  Function Length   : 306 (0x00132) Actual length = 1224 (0x0004c8)
+  Function Length   : 305 (0x00131) Actual length = 1220 (0x0004c4)
   ---- Epilog scopes ----
   ---- Scope 0
   Epilog Start Offset        : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
libraries_tests.run.linux.arm64.Release.mch
-4 (-0.04%) : 517171.dasm - System.Net.WebSockets.ManagedWebSocket:SendFrameLockAcquiredNonCancelableAsync(byte,bool,bool,System.ReadOnlyMemory`1[byte]):this (Tier1)
@@ -1382,11 +1382,10 @@ G_M17083_IG43:        ; bbWeight=1.00, gcrefRegs=F00000 {x20 x21 x22 x23}, byref
             add     x14, x23, #172
             ; byrRegs +[x14]
             movn    w15, #0
-            mov     w12, wzr
-            mov     w1, w12
+            mov     w1, wzr
             casal   w1, w15, [x14]
             cbnz    w1, G_M17083_IG56
-						;; size=28 bbWeight=1.00 PerfScore 6.98
+						;; size=24 bbWeight=1.00 PerfScore 6.48
 G_M17083_IG44:        ; bbWeight=1.00, gcrefRegs=F00000 {x20 x21 x22 x23}, byrefRegs=0000 {}, byref, isz
             ; byrRegs -[x14]
             ldr     x14, [x23, #0x18]
@@ -5017,7 +5016,7 @@ RWD64  	dq	0074007000650063h, 003D006E006F0069h
 RWD80  	dq	0074006900720057h, 00200067006E0069h
 
 
-; Total bytes of code 9952, prolog size 100, PerfScore 694.41, instruction count 2488, allocated bytes for code 9952 (MethodHash=ab05bd44) for method System.Net.WebSockets.ManagedWebSocket:SendFrameLockAcquiredNonCancelableAsync(byte,bool,bool,System.ReadOnlyMemory`1[byte]):this (Tier1)
+; Total bytes of code 9948, prolog size 100, PerfScore 693.91, instruction count 2487, allocated bytes for code 9948 (MethodHash=ab05bd44) for method System.Net.WebSockets.ManagedWebSocket:SendFrameLockAcquiredNonCancelableAsync(byte,bool,bool,System.ReadOnlyMemory`1[byte]):this (Tier1)
 ; ============================================================
 
 Unwind Info:
@@ -5028,7 +5027,7 @@ Unwind Info:
   E bit             : 0
   X bit             : 0
   Vers              : 0
-  Function Length   : 2142 (0x0085e) Actual length = 8568 (0x002178)
+  Function Length   : 2141 (0x0085d) Actual length = 8564 (0x002174)
   ---- Epilog scopes ----
   ---- Scope 0
   Epilog Start Offset        : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
libraries_tests_no_tiered_compilation.run.linux.arm64.Release.mch
-4 (-3.45%) : 47090.dasm - Autofac.Util.SequenceGenerator:GetNextUniqueSequence():long (FullOpts)
@@ -26,8 +26,7 @@ G_M46959_IG02:        ; bbWeight=8, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
             movk    x0, #0xD1FFAB1E LSL #16
             movk    x0, #0xD1FFAB1E LSL #32
             mov     x1, xzr
-            mov     x2, xzr
-            mov     x19, x2
+            mov     x19, xzr
             casal   x19, x1, [x0]
             movz    x0, #0xD1FFAB1E      // code for System.DateTime:get_UtcNow():System.DateTime
             movk    x0, #0xD1FFAB1E LSL #16
@@ -37,7 +36,7 @@ G_M46959_IG02:        ; bbWeight=8, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
             and     x0, x0, #0xD1FFAB1E
             cmp     x0, x19
             bgt     G_M46959_IG04
-						;; size=60 bbWeight=8 PerfScore 108.00
+						;; size=56 bbWeight=8 PerfScore 104.00
 G_M46959_IG03:        ; bbWeight=2, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
             add     x0, x19, #1
 						;; size=4 bbWeight=2 PerfScore 1.00
@@ -56,7 +55,7 @@ G_M46959_IG05:        ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
             ret     lr
 						;; size=12 bbWeight=1 PerfScore 3.00
 
-; Total bytes of code 116, prolog size 12, PerfScore 166.50, instruction count 29, allocated bytes for code 116 (MethodHash=7c2c4890) for method Autofac.Util.SequenceGenerator:GetNextUniqueSequence():long (FullOpts)
+; Total bytes of code 112, prolog size 12, PerfScore 162.50, instruction count 28, allocated bytes for code 112 (MethodHash=7c2c4890) for method Autofac.Util.SequenceGenerator:GetNextUniqueSequence():long (FullOpts)
 ; ============================================================
 
 Unwind Info:
@@ -67,7 +66,7 @@ Unwind Info:
   E bit             : 0
   X bit             : 0
   Vers              : 0
-  Function Length   : 29 (0x0001d) Actual length = 116 (0x000074)
+  Function Length   : 28 (0x0001c) Actual length = 112 (0x000070)
   ---- Epilog scopes ----
   ---- Scope 0
   Epilog Start Offset        : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
realworld.run.linux.arm64.checked.mch
-4 (-0.69%) : 27557.dasm - Microsoft.ApplicationInsights.Metrics.MetricSeries:GetOrCreateAggregator(int,byref):Microsoft.ApplicationInsights.Metrics.Extensibility.IMetricSeriesAggregator:this (FullOpts)
@@ -272,12 +272,10 @@ G_M61121_IG19:        ; bbWeight=0.50, gcrefRegs=1880000 {x19 x23 x24}, byrefReg
             ; gcrRegs -[x0-x1 x19]
             cbnz    w0, G_M61121_IG22
             mov     x0, xzr
-            mov     x1, x24
-            ; gcrRegs +[x1]
-            casal   x1, x0, [x21]
-						;; size=52 bbWeight=0.50 PerfScore 8.75
+            casal   x24, x0, [x21]
+						;; size=48 bbWeight=0.50 PerfScore 8.50
 G_M61121_IG20:        ; bbWeight=0.50, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
-            ; gcrRegs -[x1 x23-x24]
+            ; gcrRegs -[x23-x24]
             ; byrRegs -[x21]
             mov     x0, xzr
 						;; size=4 bbWeight=0.50 PerfScore 0.25
@@ -303,7 +301,7 @@ G_M61121_IG23:        ; bbWeight=0.50, gcrefRegs=0001 {x0}, byrefRegs=0000 {}, b
             ret     lr
 						;; size=20 bbWeight=0.50 PerfScore 2.50
 
-; Total bytes of code 580, prolog size 24, PerfScore 335.75, instruction count 145, allocated bytes for code 580 (MethodHash=db97113e) for method Microsoft.ApplicationInsights.Metrics.MetricSeries:GetOrCreateAggregator(int,byref):Microsoft.ApplicationInsights.Metrics.Extensibility.IMetricSeriesAggregator:this (FullOpts)
+; Total bytes of code 576, prolog size 24, PerfScore 335.50, instruction count 144, allocated bytes for code 576 (MethodHash=db97113e) for method Microsoft.ApplicationInsights.Metrics.MetricSeries:GetOrCreateAggregator(int,byref):Microsoft.ApplicationInsights.Metrics.Extensibility.IMetricSeriesAggregator:this (FullOpts)
 ; ============================================================
 
 Unwind Info:
@@ -314,7 +312,7 @@ Unwind Info:
   E bit             : 0
   X bit             : 0
   Vers              : 0
-  Function Length   : 145 (0x00091) Actual length = 580 (0x000244)
+  Function Length   : 144 (0x00090) Actual length = 576 (0x000240)
   ---- Epilog scopes ----
   ---- Scope 0
   Epilog Start Offset        : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)

@SwapnilGaikwad

Copy link
Copy Markdown
Contributor

cc: @dotnet/arm64-contrib @dhartglassMSFT

@SwapnilGaikwad SwapnilGaikwad mentioned this pull request Nov 25, 2026
2 of 27 tasks
Comment on lines +17 to +20
if (CompareExchangeAcrossCall() <= 0 || Volatile.Read(ref s_value) != 1)
{
throw new Exception("CompareExchange returned an unexpected result.");
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test keeps the CAS result live across GetTicks(), but never checks it equals 7. Could we also assert that the CAS result is 7? Adding positive clock ticks means an incorrect result of 0 could still pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants