Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Fix for 15671#15756

Merged
briansull merged 1 commit into
dotnet:masterfrom
briansull:fix-15671
Jan 6, 2018
Merged

Fix for 15671#15756
briansull merged 1 commit into
dotnet:masterfrom
briansull:fix-15671

Conversation

@briansull
Copy link
Copy Markdown

If we are fetching an Array Length for an array ref that came from global memory
then for CSE safety we must use the conservative value number for both

@briansull
Copy link
Copy Markdown
Author

@mikedn PTAL

@briansull
Copy link
Copy Markdown
Author

@AndyAyersMS PTAL

@AndyAyersMS
Copy link
Copy Markdown
Member

Looks plausible enough at first glance. Let me think about it a while.

Any data on the CQ/CS impact?

@mikedn
Copy link
Copy Markdown

mikedn commented Jan 5, 2018

Make sense I guess, I haven't though about using GTF_GLOB_REF since I'm not very familiar with it. My attempt was something like:

if (tree->OperIs(GT_ARR_LENGTH) && !tree->AsArrLen()->ArrRef()->gtVNPair.BothEqual())
{
    vnlib = tree->GetVN(VNK_Conservative);
}

It will be interesting to see jit-diff results, mine resulted in some 2kbytes improvements (!!!) due to CSE no longer being done in some cases. But of course, some range checks were no longer eliminated unfortunately.

@briansull
Copy link
Copy Markdown
Author

Without the check for GTF_GLOB_REF, I saw a lots of methods with large regressions, with the check, there are a mix of gains and losses, with only small method size changes. This is using the Desktop build for my diffs..

@AndyAyersMS
Copy link
Copy Markdown
Member

@dotnet/dnceng @jashook ARM64 testing seems to be in a bad way

@mikedn
Copy link
Copy Markdown

mikedn commented Jan 5, 2018

This is using the Desktop build for my diffs..

The .NET Core build produces this diff:

Total bytes of diff: 555 (0.00% of base)
    diff is a regression.
Total byte diff includes 0 bytes from reconciling methods
        Base had    0 unique methods,        0 unique bytes
        Diff had    0 unique methods,        0 unique bytes
Top file regressions by size (bytes):
         156 : Microsoft.Diagnostics.Tracing.TraceEvent.dasm (0.01% of base)
         125 : Microsoft.CSharp.dasm (0.04% of base)
         112 : System.Private.CoreLib.dasm (0.00% of base)
         101 : System.Data.Common.dasm (0.01% of base)
          32 : System.Collections.NonGeneric.dasm (0.12% of base)
Top file improvements by size (bytes):
         -54 : System.Text.RegularExpressions.dasm (-0.04% of base)
         -41 : Microsoft.CodeAnalysis.CSharp.dasm (0.00% of base)
         -25 : System.Linq.Parallel.dasm (0.00% of base)
         -25 : System.Runtime.Serialization.Formatters.dasm (-0.03% of base)
         -22 : System.Linq.Expressions.dasm (0.00% of base)
48 total files with size differences (16 improved, 32 regressed), 82 unchanged.
Top method regessions by size (bytes):
          78 : System.Private.CoreLib.dasm - List`1:EnsureCapacity(int):this (26 methods)
          61 : System.Private.CoreLib.dasm - MultiElementAsyncLocalValueMap:Set(ref,ref):ref:this
          50 : System.Data.Common.dasm - Select:CreateIndex():this
          30 : System.Private.CoreLib.dasm - Dictionary`2:TryInsert(ref,int,ubyte):bool:this (3 methods)
          27 : System.Private.Xml.dasm - XPathNodeInfoAtom:Init(ref,ref,ref,ref,ref,ref,ref,ref,int,int):this
Top method improvements by size (bytes):
         -80 : System.Private.CoreLib.dasm - DefaultBinder:BindToMethod(int,ref,byref,ref,ref,ref,byref):ref:this
         -39 : System.Text.RegularExpressions.dasm - RegexParser:ScanDollar():ref:this
         -33 : System.Private.CoreLib.dasm - Dictionary`2:FindEntry(ref):int:this (11 methods)
         -33 : System.Private.CoreLib.dasm - Dictionary`2:Remove(ref):bool:this (11 methods)
         -29 : System.Data.Common.dasm - Select:BuildLinearExpression():this
500 total methods with size differences (252 improved, 248 regressed), 140316 unchanged.

Example diff that shows a range check no longer being eliminated: https://gist.github.com/mikedn/d1f519b534806c4c29bd35e2bcbdcefb

It's unfortunate but it doesn't look like there are easy solutions to make the fix less conservative.

@briansull
Copy link
Copy Markdown
Author

@AndyAyersMS should I check this in?

@briansull briansull changed the title Proposed fix for 15671 Fix for 15671 Jan 6, 2018
@AndyAyersMS AndyAyersMS self-requested a review January 6, 2018 00:41
Copy link
Copy Markdown
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

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

Yes, looks good.

CQ impact was less than I expected, so that's a pleasant surprise.

If we are fetching an Array Length for an array ref that came from global memory
then for CSE safety we must use the conservative value number for both
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants