-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix loop cloning array index recognition for arm64 #20472
Fix loop cloning array index recognition for arm64 #20472
Conversation
arm64 Checked PMI altjit frameworks asm diffs: ``` Found 95 files with textual diffs. Summary: (Lower is better) Total bytes of diff: 30144 (0.15% of base) diff is a regression. Top file regressions by size (bytes): 11772 : System.Private.CoreLib.dasm (2.06% of base) 1768 : Microsoft.CodeAnalysis.dasm (0.26% of base) 1764 : System.Private.DataContractSerialization.dasm (0.19% of base) 1692 : Microsoft.CSharp.dasm (0.49% of base) 1436 : System.Collections.Immutable.dasm (0.16% of base) Top file improvements by size (bytes): -80 : NuGet.Packaging.dasm (-0.04% of base) -28 : xunit.execution.dotnet.dasm (-0.10% of base) -24 : Microsoft.Win32.Registry.dasm (-0.10% of base) -20 : Microsoft.DotNet.ProjectModel.dasm (-0.01% of base) -4 : System.IO.Compression.dasm (-0.01% of base) 39 total files with size differences (6 improved, 33 regressed), 90 unchanged. Top method regressions by size (bytes): 5908 (83.87% of base) : System.Private.CoreLib.dasm - System.DefaultBinder:BindToMethod(int,ref,byref,ref,ref,ref,byref):ref:this 884 (62.96% of base) : Microsoft.CSharp.dasm - Microsoft.CSharp.RuntimeBinder.Errors.ErrorHandling:Error(int,ref):ref 740 (38.14% of base) : Microsoft.VisualBasic.dasm - Microsoft.VisualBasic.CompilerServices.OverloadResolution:MoreSpecificProcedure(ref,ref,ref,ref,int,byref,bool):ref 728 (48.02% of base) : System.Private.CoreLib.dasm - System.DefaultBinder:SelectMethod(int,ref,ref,ref):ref:this 668 (38.84% of base) : System.Private.CoreLib.dasm - System.DefaultBinder:SelectProperty(int,ref,ref,ref,ref):ref:this Top method improvements by size (bytes): -80 (-2.42% of base) : NuGet.Packaging.dasm - <<InstallFromSourceAsync>b__0>d:MoveNext():this -40 (-10.10% of base) : Microsoft.Diagnostics.Tracing.TraceEvent.dasm - Microsoft.Diagnostics.Utilities.DirectoryUtilities:Clean(ref):int -32 (-5.63% of base) : System.Private.DataContractSerialization.dasm - System.Xml.XmlDictionaryReader:ReadContentAs(ref,ref):ref:this -28 (-3.24% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:CanSerializeObject(ref):bool -24 (-2.38% of base) : Microsoft.CSharp.dasm - Microsoft.CSharp.RuntimeBinder.SymbolTable:AddConversionsForOneType(ref) Top method regressions by size (percentage): 468 (110.38% of base) : System.Data.Common.dasm - System.Data.ConstraintCollection:BaseGroupSwitch(ref,int,ref,int):this 5908 (83.87% of base) : System.Private.CoreLib.dasm - System.DefaultBinder:BindToMethod(int,ref,byref,ref,ref,ref,byref):ref:this 480 (82.76% of base) : System.Web.HttpUtility.dasm - System.Web.Util.HttpEncoder:UrlEncodeUnicode(ref):ref 624 (78.00% of base) : System.Private.CoreLib.dasm - System.DefaultBinder:FindMostSpecific(ref,ref,ref,ref,ref,ref,ref,ref):int 148 (74.00% of base) : System.Private.Xml.dasm - System.Xml.ValidateNames:ParseNmtokenNoNamespaces(ref,int):int Top method improvements by size (percentage): -4 (-14.29% of base) : System.Collections.Immutable.dasm - System.Collections.Immutable.ImmutableStack`1[Int32][System.Int32]:System.Collections.Immutable.IImmutableStack<T>.Pop():ref:this -40 (-10.10% of base) : Microsoft.Diagnostics.Tracing.TraceEvent.dasm - Microsoft.Diagnostics.Utilities.DirectoryUtilities:Clean(ref):int -4 (-6.67% of base) : System.Collections.Immutable.dasm - System.Collections.Immutable.ImmutableStack`1[Int32][System.Int32]:Pop(byref):ref:this -20 (-6.58% of base) : Microsoft.DotNet.ProjectModel.dasm - Microsoft.DotNet.ProjectModel.Resolution.FrameworkReferenceResolver:GetFrameworkInformation(ref):ref:this -32 (-5.63% of base) : System.Private.DataContractSerialization.dasm - System.Xml.XmlDictionaryReader:ReadContentAs(ref,ref):ref:this 180 total methods with size differences (36 improved, 144 regressed), 100761 unchanged. 18 files had text diffs but not size diffs. System.Resources.Writer.dasm had 171 diffs System.Security.Permissions.dasm had 76 diffs System.IO.FileSystem.dasm had 40 diffs System.IO.IsolatedStorage.dasm had 34 diffs NuGet.Frameworks.dasm had 26 diffs ```
@dotnet-bot test Ubuntu16.04 arm64 Cross Checked corefx_baseline Build and Test @dotnet-bot test Ubuntu16.04 arm64 Cross Checked jitstress1 Build and Test @dotnet-bot test Ubuntu16.04 arm64 Cross Checked r2r Build and Test @dotnet-bot test Windows_NT arm64 Cross Checked corefx_baseline Build and Test @dotnet-bot test Windows_NT arm64 Cross Checked jitstress1 Build and Test @dotnet-bot test Windows_NT arm64 Cross Checked r2r Build and Test |
@AndyAyersMS I don't think we have any lab support for arm64 perf testing. Do you recommend any kind of perf testing here? |
@AndyAyersMS PTAL |
@@ -8410,7 +8410,7 @@ bool Compiler::optExtractArrIndex(GenTree* tree, ArrIndex* result, unsigned lhsN | |||
{ | |||
return false; | |||
} | |||
#ifdef _TARGET_AMD64_ // TODO-ARM64: should this be _TARGET_64BIT_? If not, add comment why not. | |||
#ifdef _TARGET_64BIT_ | |||
if (index->gtOper != GT_CAST) |
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.
What cast do we expect here for _TARGET_64BIT_
?
#else // !_TARGET_64BIT_
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.
Casts from int to long on 64 bit platforms.
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.
Did you find this by auditing ifdefs or looking at some kind of structural diff between arm64 and x64 codegen?
For perf you can try and verify that the usual suspects get cloned. Some examples to play with over in #12836. I wonder if we should have some kind of "flow graph" diff mode where we can verify that the jit produces similar flow graphs cross-arch. |
I was working in this code for #20446, and it struck me the AMD64 |
Interesting concept. I wonder how fragile it would be. There's always a worry that various optimizations just stop firing due to some minor bug like this, and we don't notice it (although this never fired for arm64, I'm sure). |
test Windows_NT arm64 Cross Checked Innerloop Build and Test Windows arm64 corefx tests have script error |
I'll do some prototyping to see if diffing flowgraphs is a viable idea. |
Jenkins reboot test Windows_NT arm64 Cross Checked Innerloop Build and Test |
@dotnet-bot test this please |
test Windows_NT arm64 Cross Checked Innerloop Build and Test |
Seems like maybe cross-arch FG diffing is viable (we'll need to revise the flow graph dump format to reduce noise a bit, and make it alt jit aware, and decide when to dump it). Opened dotnet/jitutils#177 with the intent of building something real. Here's an odd diff in ;;; x64 -- tail end of method
C3 ret
G_M43912_IG12:
E8D3DE395F call CORINFO_HELP_RNGCHKFAIL
CC int3 ;;; arm64 -- tail end of method
D65F03C0 ret lr
G_M43912_IG12:
94000000 bl CORINFO_HELP_OVERFLOW
G_M43912_IG13:
94000000 bl CORINFO_HELP_THROWDIVZERO
G_M43912_IG14:
94000000 bl CORINFO_HELP_RNGCHKFAIL
D43E0000 bkpt |
Benchmarks arm64 PMI Checked JIT (Release other components) altjit diffs:
|
A big size regression in |
…pCloningArm64 Fix loop cloning array index recognition for arm64 Commit migrated from dotnet/coreclr@679a823
arm64 Checked PMI altjit frameworks asm diffs: