-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Use cinc instead of csel when possible #82031
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch, @kunalspathak Issue DetailsUse cinc instead of csel when the true and false case are constants with a difference of 1. e.g., This avoids an addition
|
I'll make the improvements once I'm back from leave in a couple of weeks 🙂. |
@SwapnilGaikwad - let me know when you resolve the conflicts and update with the feedback. |
Change-Id: I5219abc6d2330f89f5358409704c284aaa0fd845
Seems there are superpmi-replay failures:
|
The asmdiffs with the current change are: Diffs are based on 1,484,445 contexts (402,635 MinOpts, 1,081,810 FullOpts). MISSED contexts: 1 (0.00%) Overall (-7,396 bytes)
MinOpts (+0 bytes)
FullOpts (-7,396 bytes)
Example diffsbenchmarks.run.linux.arm64.checked.mch-4 (-8.33%) : 2901.dasm - System.Reflection.Emit.OpCodes:TakesSingleByteArgument(System.Reflection.Emit.OpCode):bool@@ -22,17 +22,16 @@ G_M54669_IG02: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
ldr w0, [fp, #0x1C]
and w0, w0, #31
sub w1, w0, #15
- mov w2, #1
cmp w1, #1
ccmp w0, #18, z, hi
- csel w0, wzr, w2, ne
- ;; size=28 bbWeight=1 PerfScore 5.00
+ cinc w0, wzr, eq
+ ;; size=24 bbWeight=1 PerfScore 4.50
G_M54669_IG03: ; bbWeight=1, epilog, nogc, extend
ldp fp, lr, [sp], #0x20
ret lr
;; size=8 bbWeight=1 PerfScore 2.00
-; Total bytes of code 48, prolog size 8, PerfScore 14.30, instruction count 12, allocated bytes for code 48 (MethodHash=86ca2a72) for method System.Reflection.Emit.OpCodes:TakesSingleByteArgument(System.Reflection.Emit.OpCode):bool
+; Total bytes of code 44, prolog size 8, PerfScore 13.40, instruction count 11, allocated bytes for code 44 (MethodHash=86ca2a72) for method System.Reflection.Emit.OpCodes:TakesSingleByteArgument(System.Reflection.Emit.OpCode):bool
; ============================================================
Unwind Info:
@@ -43,7 +42,7 @@ Unwind Info:
E bit : 0
X bit : 0
Vers : 0
- Function Length : 12 (0x0000c) Actual length = 48 (0x000030)
+ Function Length : 11 (0x0000b) Actual length = 44 (0x00002c)
---- Epilog scopes ----
---- Scope 0
Epilog Start Offset : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
-4 (-8.33%) : 32035.dasm - Microsoft.CodeAnalysis.CSharp.LanguageVersionExtensionsInternal:IsValid(int):bool@@ -19,18 +19,17 @@ G_M45553_IG02: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
sub w1, w0, #1
sub w2, w0, #0xD1FFAB1E
mov w3, #0xD1FFAB1E
- mov w4, #1
cmp w1, #6
ccmp w2, #2, z, hi
ccmp w0, w3, z, hi
- csel w0, wzr, w4, ne
- ;; size=32 bbWeight=1 PerfScore 4.00
+ cinc w0, wzr, eq
+ ;; size=28 bbWeight=1 PerfScore 3.50
G_M45553_IG03: ; bbWeight=1, epilog, nogc, extend
ldp fp, lr, [sp], #0x10
ret lr
;; size=8 bbWeight=1 PerfScore 2.00
-; Total bytes of code 48, prolog size 8, PerfScore 12.30, instruction count 12, allocated bytes for code 48 (MethodHash=a2564e0e) for method Microsoft.CodeAnalysis.CSharp.LanguageVersionExtensionsInternal:IsValid(int):bool
+; Total bytes of code 44, prolog size 8, PerfScore 11.40, instruction count 11, allocated bytes for code 44 (MethodHash=a2564e0e) for method Microsoft.CodeAnalysis.CSharp.LanguageVersionExtensionsInternal:IsValid(int):bool
; ============================================================
Unwind Info:
@@ -41,7 +40,7 @@ Unwind Info:
E bit : 0
X bit : 0
Vers : 0
- Function Length : 12 (0x0000c) Actual length = 48 (0x000030)
+ Function Length : 11 (0x0000b) Actual length = 44 (0x00002c)
---- Epilog scopes ----
---- Scope 0
Epilog Start Offset : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
-4 (-8.33%) : 32185.dasm - Microsoft.CodeAnalysis.CSharp.ErrorFacts:IsHidden(int):bool@@ -20,17 +20,16 @@ G_M60755_IG02: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
add w1, w0, w1
movn w2, #0xD1FFAB1E
add w0, w0, w2
- mov w2, #1
cmp w1, #1
ccmp w0, #2, z, hi
- csel w0, wzr, w2, hi
- ;; size=32 bbWeight=1 PerfScore 4.00
+ cinc w0, wzr, ls
+ ;; size=28 bbWeight=1 PerfScore 3.50
G_M60755_IG03: ; bbWeight=1, epilog, nogc, extend
ldp fp, lr, [sp], #0x10
ret lr
;; size=8 bbWeight=1 PerfScore 2.00
-; Total bytes of code 48, prolog size 8, PerfScore 12.30, instruction count 12, allocated bytes for code 48 (MethodHash=781f12ac) for method Microsoft.CodeAnalysis.CSharp.ErrorFacts:IsHidden(int):bool
+; Total bytes of code 44, prolog size 8, PerfScore 11.40, instruction count 11, allocated bytes for code 44 (MethodHash=781f12ac) for method Microsoft.CodeAnalysis.CSharp.ErrorFacts:IsHidden(int):bool
; ============================================================
Unwind Info:
@@ -41,7 +40,7 @@ Unwind Info:
E bit : 0
X bit : 0
Vers : 0
- Function Length : 12 (0x0000c) Actual length = 48 (0x000030)
+ Function Length : 11 (0x0000b) Actual length = 44 (0x00002c)
---- Epilog scopes ----
---- Scope 0
Epilog Start Offset : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
+0 (0.00%) : 1589.dasm - System.Collections.Generic.GenericComparer`1[System.__Canon]:Compare(System.__Canon,System.__Canon):int:this@@ -79,7 +79,7 @@ G_M55125_IG10: ; bbWeight=0.50, gcVars=0000000000000000 {}, gcrefRegs=280
; gcrRegs +[x19]
movn w0, #0
cmp x19, #0
- csel w0, wzr, w0, eq
+ cinc w0, w0, eq
;; size=12 bbWeight=0.50 PerfScore 0.75
G_M55125_IG11: ; bbWeight=0.50, epilog, nogc, extend
ldr x21, [sp, #0x28]
+0 (0.00%) : 21369.dasm - Microsoft.Extensions.Configuration.ConfigurationKeyComparer:Compare(System.String,System.String):int:this@@ -447,7 +447,7 @@ G_M45805_IG25: ; bbWeight=0.50, gcrefRegs=0000 {}, byrefRegs=0000 {}, byr
G_M45805_IG26: ; bbWeight=0.50, gcVars=0000000000000000 {}, gcrefRegs=0000 {}, byrefRegs=0000 {}, gcvars, byref
movn w0, #0
cmp w22, #0
- csel w0, wzr, w0, eq
+ cinc w0, w0, eq
;; size=12 bbWeight=0.50 PerfScore 0.75
G_M45805_IG27: ; bbWeight=0.50, epilog, nogc, extend
ldr x27, [sp, #0x58]
+0 (0.00%) : 31102.dasm - System.Globalization.CompareInfo:Compare(System.String,int,int,System.String,int,int,int):int:this@@ -108,7 +108,7 @@ G_M40521_IG07: ; bbWeight=0.50, gcVars=0000000000000000 {}, gcrefRegs=800
; GC ptr vars -{V31}
movn w0, #0
cmp x19, #0
- csel w0, wzr, w0, eq
+ cinc w0, w0, eq
;; size=12 bbWeight=0.50 PerfScore 0.75
G_M40521_IG08: ; bbWeight=0.50, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref, isz
; gcrRegs -[x19]
libraries_tests.pmi.linux.arm64.checked.mch-4 (-12.50%) : 140370.dasm - ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.inheritance.multi03c.multi03c.Derived:Foo(int,int):int:this@@ -18,17 +18,16 @@ G_M44436_IG01: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
mov fp, sp
;; size=8 bbWeight=1 PerfScore 1.50
G_M44436_IG02: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
- mov w0, #1
cmp w1, #2
ccmp w2, #2, 0, eq
- csel w0, w0, wzr, ne
- ;; size=16 bbWeight=1 PerfScore 2.00
+ cinc w0, wzr, ne
+ ;; size=12 bbWeight=1 PerfScore 1.50
G_M44436_IG03: ; bbWeight=1, epilog, nogc, extend
ldp fp, lr, [sp], #0x10
ret lr
;; size=8 bbWeight=1 PerfScore 2.00
-; Total bytes of code 32, prolog size 8, PerfScore 8.70, instruction count 8, allocated bytes for code 32 (MethodHash=e4e0526b) for method ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.inheritance.multi03c.multi03c.Derived:Foo(int,int):int:this
+; Total bytes of code 28, prolog size 8, PerfScore 7.80, instruction count 7, allocated bytes for code 28 (MethodHash=e4e0526b) for method ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.inheritance.multi03c.multi03c.Derived:Foo(int,int):int:this
; ============================================================
Unwind Info:
@@ -39,7 +38,7 @@ Unwind Info:
E bit : 0
X bit : 0
Vers : 0
- Function Length : 8 (0x00008) Actual length = 32 (0x000020)
+ Function Length : 7 (0x00007) Actual length = 28 (0x00001c)
---- Epilog scopes ----
---- Scope 0
Epilog Start Offset : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
-4 (-12.50%) : 175194.dasm - Analyzer.Utilities.DisposeAnalysisKindExtensions:AreMayBeNotDisposedViolationsEnabled(int):bool@@ -17,17 +17,16 @@ G_M11524_IG01: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
mov fp, sp
;; size=8 bbWeight=1 PerfScore 1.50
G_M11524_IG02: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
- mov w1, #1
cmp w0, #1
ccmp w0, #3, z, ne
- csel w0, w1, wzr, ne
- ;; size=16 bbWeight=1 PerfScore 2.00
+ cinc w0, wzr, ne
+ ;; size=12 bbWeight=1 PerfScore 1.50
G_M11524_IG03: ; bbWeight=1, epilog, nogc, extend
ldp fp, lr, [sp], #0x10
ret lr
;; size=8 bbWeight=1 PerfScore 2.00
-; Total bytes of code 32, prolog size 8, PerfScore 8.70, instruction count 8, allocated bytes for code 32 (MethodHash=22a7d2fb) for method Analyzer.Utilities.DisposeAnalysisKindExtensions:AreMayBeNotDisposedViolationsEnabled(int):bool
+; Total bytes of code 28, prolog size 8, PerfScore 7.80, instruction count 7, allocated bytes for code 28 (MethodHash=22a7d2fb) for method Analyzer.Utilities.DisposeAnalysisKindExtensions:AreMayBeNotDisposedViolationsEnabled(int):bool
; ============================================================
Unwind Info:
@@ -38,7 +37,7 @@ Unwind Info:
E bit : 0
X bit : 0
Vers : 0
- Function Length : 8 (0x00008) Actual length = 32 (0x000020)
+ Function Length : 7 (0x00007) Actual length = 28 (0x00001c)
---- Epilog scopes ----
---- Scope 0
Epilog Start Offset : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
-4 (-12.50%) : 248154.dasm - NuGet.Protocol.Plugins.MessageDispatcher:GetIsKeepAlive(NuGet.Protocol.Plugins.IConnection,int,int):bool@@ -18,17 +18,16 @@ G_M27270_IG01: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
mov fp, sp
;; size=8 bbWeight=1 PerfScore 1.50
G_M27270_IG02: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
- mov w0, #1
cmp w1, #3
ccmp w2, #10, 0, eq
- csel w0, w0, wzr, ne
- ;; size=16 bbWeight=1 PerfScore 2.00
+ cinc w0, wzr, ne
+ ;; size=12 bbWeight=1 PerfScore 1.50
G_M27270_IG03: ; bbWeight=1, epilog, nogc, extend
ldp fp, lr, [sp], #0x10
ret lr
;; size=8 bbWeight=1 PerfScore 2.00
-; Total bytes of code 32, prolog size 8, PerfScore 8.70, instruction count 8, allocated bytes for code 32 (MethodHash=8d359579) for method NuGet.Protocol.Plugins.MessageDispatcher:GetIsKeepAlive(NuGet.Protocol.Plugins.IConnection,int,int):bool
+; Total bytes of code 28, prolog size 8, PerfScore 7.80, instruction count 7, allocated bytes for code 28 (MethodHash=8d359579) for method NuGet.Protocol.Plugins.MessageDispatcher:GetIsKeepAlive(NuGet.Protocol.Plugins.IConnection,int,int):bool
; ============================================================
Unwind Info:
@@ -39,7 +38,7 @@ Unwind Info:
E bit : 0
X bit : 0
Vers : 0
- Function Length : 8 (0x00008) Actual length = 32 (0x000020)
+ Function Length : 7 (0x00007) Actual length = 28 (0x00001c)
---- Epilog scopes ----
---- Scope 0
Epilog Start Offset : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
+0 (0.00%) : 278974.dasm - Stashbox.Utils.Data.ExpandableArray`1[double]:IndexOf(double):int:this@@ -61,7 +61,7 @@ G_M800_IG03: ; bbWeight=0.50, gcrefRegs=80000 {x19}, byrefRegs=0000 {}, b
str d8, [x0, #0x08]
movn w1, #0
cmp x20, x0
- csel w0, wzr, w1, eq
+ cinc w0, w1, eq
; gcrRegs -[x0]
;; size=72 bbWeight=0.50 PerfScore 9.50
G_M800_IG04: ; bbWeight=0.50, epilog, nogc, extend
+0 (0.00%) : 179712.dasm - Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.AnalysisEntityFactory:TryCreate(Microsoft.CodeAnalysis.IOperation,byref):bool:this@@ -1036,13 +1036,13 @@ G_M28439_IG28: ; bbWeight=0.50, gcrefRegs=12A80000 {x19 x21 x23 x25 x28},
ldr x1, [x11]
blr x1
; gcrRegs -[x0]
- mov w1, #2
- mov w2, #1
+ mov w1, #1
cmp w0, #0
- csel w22, w1, w2, ne
+ cinc w22, w1, ne
movz x0, #0xD1FFAB1E
movk x0, #0xD1FFAB1E LSL #16
movk x0, #0xD1FFAB1E LSL #32
+ mov x1, #2
bl CORINFO_HELP_NEWARR_1_OBJ
; gcrRegs +[x0]
mov x24, x0
+0 (0.00%) : 269824.dasm - FluentAssertions.Specialized.ExecutionTimeAssertions:BeGreaterThan(System.TimeSpan,System.String,System.Object[]):FluentAssertions.AndConstraint`1[FluentAssertions.Specialized.ExecutionTimeAssertions]:this@@ -128,7 +128,7 @@ G_M43739_IG03: ; bbWeight=0.50, gcrefRegs=B80001 {x0 x19 x20 x21 x23}, by
G_M43739_IG04: ; bbWeight=0.50, gcrefRegs=B80001 {x0 x19 x20 x21 x23}, byrefRegs=0000 {}, byref
movn w1, #0
cmp x24, x2
- csel w1, wzr, w1, ge
+ cinc w1, w1, ge
;; size=12 bbWeight=0.50 PerfScore 0.75
G_M43739_IG05: ; bbWeight=1, gcrefRegs=B80001 {x0 x19 x20 x21 x23}, byrefRegs=0000 {}, byref, isz
cmp w1, #0
libraries.crossgen2.linux.arm64.checked.mch-4 (-12.50%) : 158811.dasm - System.Security.Cryptography.X509Certificates.OpenSslX509ChainProcessor:IsCompleteChain(Interop+Crypto+X509VerifyStatusCode):bool@@ -20,17 +20,16 @@ G_M10905_IG01: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
mov fp, sp
;; size=8 bbWeight=1 PerfScore 1.50
G_M10905_IG02: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
- mov w1, #1
cmp w0, #2
ccmp w0, #20, z, ne
- csel w0, w1, wzr, ne
- ;; size=16 bbWeight=1 PerfScore 2.00
+ cinc w0, wzr, ne
+ ;; size=12 bbWeight=1 PerfScore 1.50
G_M10905_IG03: ; bbWeight=1, epilog, nogc, extend
ldp fp, lr, [sp], #0x10
ret lr
;; size=8 bbWeight=1 PerfScore 2.00
-; Total bytes of code 32, prolog size 8, PerfScore 8.70, instruction count 8, allocated bytes for code 32 (MethodHash=9f73d566) for method System.Security.Cryptography.X509Certificates.OpenSslX509ChainProcessor:IsCompleteChain(Interop+Crypto+X509VerifyStatusCode):bool
+; Total bytes of code 28, prolog size 8, PerfScore 7.80, instruction count 7, allocated bytes for code 28 (MethodHash=9f73d566) for method System.Security.Cryptography.X509Certificates.OpenSslX509ChainProcessor:IsCompleteChain(Interop+Crypto+X509VerifyStatusCode):bool
; ============================================================
Unwind Info:
@@ -41,7 +40,7 @@ Unwind Info:
E bit : 0
X bit : 0
Vers : 0
- Function Length : 8 (0x00008) Actual length = 32 (0x000020)
+ Function Length : 7 (0x00007) Actual length = 28 (0x00001c)
---- Epilog scopes ----
---- Scope 0
Epilog Start Offset : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
-4 (-12.50%) : 133856.dasm - Roslyn.Utilities.UnicodeCharacterUtilities:IsLetterChar(int):bool@@ -17,17 +17,16 @@ G_M56201_IG01: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
mov fp, sp
;; size=8 bbWeight=1 PerfScore 1.50
G_M56201_IG02: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
- mov w1, #1
cmp w0, #4
ccmp w0, #9, z, hi
- csel w0, wzr, w1, ne
- ;; size=16 bbWeight=1 PerfScore 2.00
+ cinc w0, wzr, eq
+ ;; size=12 bbWeight=1 PerfScore 1.50
G_M56201_IG03: ; bbWeight=1, epilog, nogc, extend
ldp fp, lr, [sp], #0x10
ret lr
;; size=8 bbWeight=1 PerfScore 2.00
-; Total bytes of code 32, prolog size 8, PerfScore 8.70, instruction count 8, allocated bytes for code 32 (MethodHash=18a32476) for method Roslyn.Utilities.UnicodeCharacterUtilities:IsLetterChar(int):bool
+; Total bytes of code 28, prolog size 8, PerfScore 7.80, instruction count 7, allocated bytes for code 28 (MethodHash=18a32476) for method Roslyn.Utilities.UnicodeCharacterUtilities:IsLetterChar(int):bool
; ============================================================
Unwind Info:
@@ -38,7 +37,7 @@ Unwind Info:
E bit : 0
X bit : 0
Vers : 0
- Function Length : 8 (0x00008) Actual length = 32 (0x000020)
+ Function Length : 7 (0x00007) Actual length = 28 (0x00001c)
---- Epilog scopes ----
---- Scope 0
Epilog Start Offset : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
-4 (-12.50%) : 136423.dasm - Microsoft.CodeAnalysis.PrimitiveTypeCodeExtensions:Is64BitIntegral(int):bool@@ -17,17 +17,16 @@ G_M18810_IG01: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
mov fp, sp
;; size=8 bbWeight=1 PerfScore 1.50
G_M18810_IG02: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
- mov w1, #1
cmp w0, #7
ccmp w0, #15, z, ne
- csel w0, wzr, w1, ne
- ;; size=16 bbWeight=1 PerfScore 2.00
+ cinc w0, wzr, eq
+ ;; size=12 bbWeight=1 PerfScore 1.50
G_M18810_IG03: ; bbWeight=1, epilog, nogc, extend
ldp fp, lr, [sp], #0x10
ret lr
;; size=8 bbWeight=1 PerfScore 2.00
-; Total bytes of code 32, prolog size 8, PerfScore 8.70, instruction count 8, allocated bytes for code 32 (MethodHash=1f3db685) for method Microsoft.CodeAnalysis.PrimitiveTypeCodeExtensions:Is64BitIntegral(int):bool
+; Total bytes of code 28, prolog size 8, PerfScore 7.80, instruction count 7, allocated bytes for code 28 (MethodHash=1f3db685) for method Microsoft.CodeAnalysis.PrimitiveTypeCodeExtensions:Is64BitIntegral(int):bool
; ============================================================
Unwind Info:
@@ -38,7 +37,7 @@ Unwind Info:
E bit : 0
X bit : 0
Vers : 0
- Function Length : 8 (0x00008) Actual length = 32 (0x000020)
+ Function Length : 7 (0x00007) Actual length = 28 (0x00001c)
---- Epilog scopes ----
---- Scope 0
Epilog Start Offset : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
+0 (0.00%) : 79102.dasm - Microsoft.FSharp.Core.FSharpChoice`5[System.__Canon,System.__Canon,System.__Canon,System.__Canon,System.__Canon]:CompareTo(Microsoft.FSharp.Core.FSharpChoice`5[System.__Canon,System.__Canon,System.__Canon,System.__Canon,System.__Canon]):int:this@@ -64,7 +64,7 @@ G_M39560_IG07: ; bbWeight=0.50, gcVars=0000000000000000 {}, gcrefRegs=180
; gcrRegs +[x20]
movn w0, #0
cmp x20, #0
- csel w0, wzr, w0, eq
+ cinc w0, w0, eq
;; size=12 bbWeight=0.50 PerfScore 0.75
G_M39560_IG08: ; bbWeight=0.50, epilog, nogc, extend
ldp x19, x20, [sp, #0x20]
+0 (0.00%) : 79551.dasm - Microsoft.FSharp.Collections.SetTreeModule:compare[System.__Canon](System.Collections.Generic.IComparer`1[System.__Canon],Microsoft.FSharp.Collections.SetTree`1[System.__Canon],Microsoft.FSharp.Collections.SetTree`1[System.__Canon]):int@@ -47,7 +47,7 @@ G_M15074_IG03: ; bbWeight=0.50, gcrefRegs=100000 {x20}, byrefRegs=0000 {}
; gcrRegs -[x21-x22]
movn w0, #0
cmp x20, #0
- csel w0, w0, wzr, ne
+ cinc w0, w0, eq
;; size=12 bbWeight=0.50 PerfScore 0.75
G_M15074_IG04: ; bbWeight=0.50, epilog, nogc, extend
ldp x23, x24, [sp, #0x40]
+0 (0.00%) : 169088.dasm - Microsoft.Extensions.Configuration.ConfigurationKeyComparer:Compare(System.String,System.String):int:this@@ -270,7 +270,7 @@ G_M45805_IG23: ; bbWeight=0.50, gcVars=0000000000000000 {}, gcrefRegs=000
ldr w0, [fp, #0xB0]
movn w1, #0
cmp w0, #0
- csel w0, wzr, w1, eq
+ cinc w0, w1, eq
;; size=16 bbWeight=0.50 PerfScore 1.75
G_M45805_IG24: ; bbWeight=0.50, epilog, nogc, extend
ldr x21, [sp, #0xD8]
libraries.pmi.linux.arm64.checked.mch-4 (-12.50%) : 134083.dasm - Microsoft.CodeAnalysis.ThreeStateHelpers:ToThreeState(bool):ubyte@@ -16,17 +16,16 @@ G_M30959_IG01: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
mov fp, sp
;; size=8 bbWeight=1 PerfScore 1.50
G_M30959_IG02: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
- mov w1, #2
- mov w2, #1
+ mov w1, #1
tst w0, #255
- csel w0, w1, w2, ne
- ;; size=16 bbWeight=1 PerfScore 2.00
+ cinc w0, w1, ne
+ ;; size=12 bbWeight=1 PerfScore 1.50
G_M30959_IG03: ; bbWeight=1, epilog, nogc, extend
ldp fp, lr, [sp], #0x10
ret lr
;; size=8 bbWeight=1 PerfScore 2.00
-; Total bytes of code 32, prolog size 8, PerfScore 8.70, instruction count 8, allocated bytes for code 32 (MethodHash=cce18710) for method Microsoft.CodeAnalysis.ThreeStateHelpers:ToThreeState(bool):ubyte
+; Total bytes of code 28, prolog size 8, PerfScore 7.80, instruction count 7, allocated bytes for code 28 (MethodHash=cce18710) for method Microsoft.CodeAnalysis.ThreeStateHelpers:ToThreeState(bool):ubyte
; ============================================================
Unwind Info:
@@ -37,7 +36,7 @@ Unwind Info:
E bit : 0
X bit : 0
Vers : 0
- Function Length : 8 (0x00008) Actual length = 32 (0x000020)
+ Function Length : 7 (0x00007) Actual length = 28 (0x00001c)
---- Epilog scopes ----
---- Scope 0
Epilog Start Offset : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
-4 (-12.50%) : 176774.dasm - Microsoft.CodeAnalysis.PrimitiveTypeCodeExtensions:IsFloatingPoint(int):bool@@ -16,17 +16,16 @@ G_M35125_IG01: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
mov fp, sp
;; size=8 bbWeight=1 PerfScore 1.50
G_M35125_IG02: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
- mov w1, #1
cmp w0, #3
ccmp w0, #4, z, ne
- csel w0, wzr, w1, ne
- ;; size=16 bbWeight=1 PerfScore 2.00
+ cinc w0, wzr, eq
+ ;; size=12 bbWeight=1 PerfScore 1.50
G_M35125_IG03: ; bbWeight=1, epilog, nogc, extend
ldp fp, lr, [sp], #0x10
ret lr
;; size=8 bbWeight=1 PerfScore 2.00
-; Total bytes of code 32, prolog size 8, PerfScore 8.70, instruction count 8, allocated bytes for code 32 (MethodHash=210876ca) for method Microsoft.CodeAnalysis.PrimitiveTypeCodeExtensions:IsFloatingPoint(int):bool
+; Total bytes of code 28, prolog size 8, PerfScore 7.80, instruction count 7, allocated bytes for code 28 (MethodHash=210876ca) for method Microsoft.CodeAnalysis.PrimitiveTypeCodeExtensions:IsFloatingPoint(int):bool
; ============================================================
Unwind Info:
@@ -37,7 +36,7 @@ Unwind Info:
E bit : 0
X bit : 0
Vers : 0
- Function Length : 8 (0x00008) Actual length = 32 (0x000020)
+ Function Length : 7 (0x00007) Actual length = 28 (0x00001c)
---- Epilog scopes ----
---- Scope 0
Epilog Start Offset : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
-4 (-12.50%) : 137735.dasm - Microsoft.CodeAnalysis.Text.SourceHashAlgorithms:IsSupportedAlgorithm(int):bool@@ -17,17 +17,16 @@ G_M57942_IG01: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
mov fp, sp
;; size=8 bbWeight=1 PerfScore 1.50
G_M57942_IG02: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
- mov w1, #1
cmp w0, #1
ccmp w0, #2, z, ne
- csel w0, wzr, w1, ne
- ;; size=16 bbWeight=1 PerfScore 2.00
+ cinc w0, wzr, eq
+ ;; size=12 bbWeight=1 PerfScore 1.50
G_M57942_IG03: ; bbWeight=1, epilog, nogc, extend
ldp fp, lr, [sp], #0x10
ret lr
;; size=8 bbWeight=1 PerfScore 2.00
-; Total bytes of code 32, prolog size 8, PerfScore 8.70, instruction count 8, allocated bytes for code 32 (MethodHash=c7761da9) for method Microsoft.CodeAnalysis.Text.SourceHashAlgorithms:IsSupportedAlgorithm(int):bool
+; Total bytes of code 28, prolog size 8, PerfScore 7.80, instruction count 7, allocated bytes for code 28 (MethodHash=c7761da9) for method Microsoft.CodeAnalysis.Text.SourceHashAlgorithms:IsSupportedAlgorithm(int):bool
; ============================================================
Unwind Info:
@@ -38,7 +37,7 @@ Unwind Info:
E bit : 0
X bit : 0
Vers : 0
- Function Length : 8 (0x00008) Actual length = 32 (0x000020)
+ Function Length : 7 (0x00007) Actual length = 28 (0x00001c)
---- Epilog scopes ----
---- Scope 0
Epilog Start Offset : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
+0 (0.00%) : 165695.dasm - System.Data.Common.DateTimeOffsetStorage:CompareValueTo(int,System.Object):int:this@@ -219,7 +219,7 @@ G_M63969_IG10: ; bbWeight=0.50, gcrefRegs=0000 {}, byrefRegs=0000 {}, byr
; gcrRegs -[x21]
movn w2, #0
cmp x0, x1
- csel w0, wzr, w2, ge
+ cinc w0, w2, ge
;; size=12 bbWeight=0.50 PerfScore 0.75
G_M63969_IG11: ; bbWeight=0.50, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref, epilog, nogc
ldr x21, [sp, #0x78]
+0 (0.00%) : 194175.dasm - System.ComponentModel.CultureInfoConverter+CultureComparer:Compare(System.Object,System.Object):int:this@@ -42,7 +42,7 @@ G_M57642_IG03: ; bbWeight=0.50, gcrefRegs=80000 {x19}, byrefRegs=0000 {},
; gcrRegs -[x1 x20]
movn w0, #0
cmp x19, #0
- csel w0, w0, wzr, ne
+ cinc w0, w0, eq
;; size=12 bbWeight=0.50 PerfScore 0.75
G_M57642_IG04: ; bbWeight=0.50, epilog, nogc, extend
ldr x21, [sp, #0x28]
+0 (0.00%) : 108032.dasm - Microsoft.FSharp.Core.FSharpChoice`2[ubyte,System.Nullable`1[int]]:CompareTo(Microsoft.FSharp.Core.FSharpChoice`2[ubyte,System.Nullable`1[int]]):int:this@@ -249,7 +249,7 @@ G_M3528_IG16: ; bbWeight=0.50, gcVars=0000000000000000 {}, gcrefRegs=1000
; gcrRegs +[x20]
movn w0, #0
cmp x20, #0
- csel w0, wzr, w0, eq
+ cinc w0, w0, eq
;; size=12 bbWeight=0.50 PerfScore 0.75
G_M3528_IG17: ; bbWeight=0.50, epilog, nogc, extend
ldr x21, [sp, #0x28]
coreclr_tests.run.linux.arm64.checked.mch-4 (-12.50%) : 269242.dasm - Microsoft.CodeAnalysis.ThreeStateHelpers:ToThreeState(bool):ubyte@@ -17,17 +17,16 @@ G_M30959_IG01: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
mov fp, sp
;; size=8 bbWeight=1 PerfScore 1.50
G_M30959_IG02: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
- mov w1, #2
- mov w2, #1
+ mov w1, #1
tst w0, #255
- csel w0, w1, w2, ne
- ;; size=16 bbWeight=1 PerfScore 2.00
+ cinc w0, w1, ne
+ ;; size=12 bbWeight=1 PerfScore 1.50
G_M30959_IG03: ; bbWeight=1, epilog, nogc, extend
ldp fp, lr, [sp], #0x10
ret lr
;; size=8 bbWeight=1 PerfScore 2.00
-; Total bytes of code 32, prolog size 8, PerfScore 8.70, instruction count 8, allocated bytes for code 32 (MethodHash=cce18710) for method Microsoft.CodeAnalysis.ThreeStateHelpers:ToThreeState(bool):ubyte
+; Total bytes of code 28, prolog size 8, PerfScore 7.80, instruction count 7, allocated bytes for code 28 (MethodHash=cce18710) for method Microsoft.CodeAnalysis.ThreeStateHelpers:ToThreeState(bool):ubyte
; ============================================================
Unwind Info:
@@ -38,7 +37,7 @@ Unwind Info:
E bit : 0
X bit : 0
Vers : 0
- Function Length : 8 (0x00008) Actual length = 32 (0x000020)
+ Function Length : 7 (0x00007) Actual length = 28 (0x00001c)
---- Epilog scopes ----
---- Scope 0
Epilog Start Offset : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
-4 (-11.11%) : 624528.dasm - TestConfig:Verify_ServerGC_Env_Disable(System.String[]):int@@ -17,17 +17,16 @@ G_M1580_IG01: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
;; size=8 bbWeight=1 PerfScore 1.50
G_M1580_IG02: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
bl <unknown method>
- mov w1, #101
- mov w2, #100
+ mov w1, #100
cmp w0, #0
- csel w0, w1, w2, ne
- ;; size=20 bbWeight=1 PerfScore 3.00
+ cinc w0, w1, ne
+ ;; size=16 bbWeight=1 PerfScore 2.50
G_M1580_IG03: ; bbWeight=1, epilog, nogc, extend
ldp fp, lr, [sp], #0x10
ret lr
;; size=8 bbWeight=1 PerfScore 2.00
-; Total bytes of code 36, prolog size 8, PerfScore 10.10, instruction count 9, allocated bytes for code 36 (MethodHash=9ca5f9d3) for method TestConfig:Verify_ServerGC_Env_Disable(System.String[]):int
+; Total bytes of code 32, prolog size 8, PerfScore 9.20, instruction count 8, allocated bytes for code 32 (MethodHash=9ca5f9d3) for method TestConfig:Verify_ServerGC_Env_Disable(System.String[]):int
; ============================================================
Unwind Info:
@@ -38,7 +37,7 @@ Unwind Info:
E bit : 0
X bit : 0
Vers : 0
- Function Length : 9 (0x00009) Actual length = 36 (0x000024)
+ Function Length : 8 (0x00008) Actual length = 32 (0x000020)
---- Epilog scopes ----
---- Scope 0
Epilog Start Offset : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
-4 (-11.11%) : 624529.dasm - TestConfig:Verify_ServerGC_Env_Enable(System.String[]):int@@ -18,16 +18,15 @@ G_M37081_IG01: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
G_M37081_IG02: ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
bl <unknown method>
mov w1, #100
- mov w2, #101
cmp w0, #0
- csel w0, w1, w2, ne
- ;; size=20 bbWeight=1 PerfScore 3.00
+ cinc w0, w1, eq
+ ;; size=16 bbWeight=1 PerfScore 2.50
G_M37081_IG03: ; bbWeight=1, epilog, nogc, extend
ldp fp, lr, [sp], #0x10
ret lr
;; size=8 bbWeight=1 PerfScore 2.00
-; Total bytes of code 36, prolog size 8, PerfScore 10.10, instruction count 9, allocated bytes for code 36 (MethodHash=a5706f26) for method TestConfig:Verify_ServerGC_Env_Enable(System.String[]):int
+; Total bytes of code 32, prolog size 8, PerfScore 9.20, instruction count 8, allocated bytes for code 32 (MethodHash=a5706f26) for method TestConfig:Verify_ServerGC_Env_Enable(System.String[]):int
; ============================================================
Unwind Info:
@@ -38,7 +37,7 @@ Unwind Info:
E bit : 0
X bit : 0
Vers : 0
- Function Length : 9 (0x00009) Actual length = 36 (0x000024)
+ Function Length : 8 (0x00008) Actual length = 32 (0x000020)
---- Epilog scopes ----
---- Scope 0
Epilog Start Offset : 3523193630 (0xd1ffab1e) Actual offset = 3523193630 (0xd1ffab1e) Offset from main function begin = 3523193630 (0xd1ffab1e)
+0 (0.00%) : 368307.dasm - test:Main():intNo diffs found? +0 (0.00%) : 449268.dasm - JIT.HardwareIntrinsics.Arm._AdvSimd.Arm64.SimpleBinaryOpTest__AddSaturateScalar_Vector64_UInt32_Vector64_Int32:ValidateResult(uint[],int[],uint[],System.String):this@@ -318,7 +318,7 @@ G_M11776_IG03: ; bbWeight=0.50, gcrefRegs=F80000 {x19 x20 x21 x22 x23}, b
G_M11776_IG04: ; bbWeight=0.50, gcrefRegs=F80000 {x19 x20 x21 x22 x23}, byrefRegs=0000 {}, byref
movn w1, #0
cmp w0, w24
- csel w0, w1, wzr, lo
+ cinc w0, w1, hs
;; size=12 bbWeight=0.50 PerfScore 0.75
G_M11776_IG05: ; bbWeight=1, gcrefRegs=F80000 {x19 x20 x21 x22 x23}, byrefRegs=0000 {}, byref, isz
ldr w1, [x19, #0x08]
+0 (0.00%) : 347645.dasm - System.Collections.Generic.GenericComparer`1[System.__Canon]:Compare(System.__Canon,System.__Canon):int:this@@ -79,7 +79,7 @@ G_M55125_IG09: ; bbWeight=0, gcVars=0000000000000000 {}, gcrefRegs=280000
; gcrRegs +[x19]
movn w0, #0
cmp x19, #0
- csel w0, wzr, w0, eq
+ cinc w0, w0, eq
;; size=12 bbWeight=0 PerfScore 0.00
G_M55125_IG10: ; bbWeight=0, epilog, nogc, extend
ldr x21, [sp, #0x28]
DetailsImprovements/regressions per collection
Context information
jit-analyze output |
size_t op1Val = (size_t)trueVal->AsIntCon()->IconValue(); | ||
size_t op2Val = (size_t)falseVal->AsIntCon()->IconValue(); | ||
|
||
if (op1Val + 1 == op2Val || op2Val + 1 == op1Val) |
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.
Nit for future PRs: we parenthesize all subexpressions: https://github.com/dotnet/runtime/blob/main/docs/coding-guidelines/clr-jit-coding-conventions.md#111-logical-and-arithmetic-expressions
Let's not rerun CI to fix this, though.
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.
Cool, thanks. I will piggyback these changes along with the next related patch (probably cinv
).
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.
Use cinc instead of csel when the true and false case are constants with a difference of 1.
e.g.,
result = a > 42 ? 6: 5
This avoids an addition
mov
instr for the larger value.Related: #55364