JIT: Teach middle-end liveness to DCE dead calls without sideeffects#106183
Closed
jakobbotsch wants to merge 2 commits intodotnet:mainfrom
Closed
JIT: Teach middle-end liveness to DCE dead calls without sideeffects#106183jakobbotsch wants to merge 2 commits intodotnet:mainfrom
jakobbotsch wants to merge 2 commits intodotnet:mainfrom
Conversation
Currently only the backend liveness pass will DCE calls without side effects when their result is unused. However, unused runtime lookups can end up expanded to control flow that we will be unable to DCE. This teaches the middle-end liveness pass to DCE dead calls as well. Fix dotnet#106129
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Member
Author
|
@EgorBot -amd -arm64 using System.Net;
using BenchmarkDotNet.Attributes;
namespace genericlist
{
public sealed class BinaryTrie
{
[System.Runtime.CompilerServices.InlineArray(2)]
public struct TwoBranches<TNodeLeaf>
{
private TNodeLeaf? _ref0;
}
public class Node<TNodeLeaf>
{
public TwoBranches<Node<TNodeLeaf>> Branches;
public Node<TNodeLeaf> n0;
public Node<TNodeLeaf> n1;
public bool IsLeaf;
public TNodeLeaf? NodeLeaf;
}
public static TLeaf? LookupInlineArray<TLeaf>(Node<TLeaf> root)
{
Node<TLeaf> currentNode = root;
TLeaf? result = default;
for (int i = 0; i < 8; i++)
{
int bit = i % 2;
Node<TLeaf>? branch = currentNode.Branches[bit];
if (branch is not null)
{
return result;
}
}
return result;
}
public static TLeaf? LookupTernary<TLeaf>(Node<TLeaf> root)
{
Node<TLeaf> currentNode = root;
TLeaf? result = default;
for (int i = 0; i < 8; i++)
{
int bit = i % 2;
Node<TLeaf>? branch = bit == 0 ? currentNode.n0 : currentNode.n1;
if (branch is not null)
{
return result;
}
}
return result;
}
}
[DisassemblyDiagnoser]
public class Benchmarks
{
BinaryTrie.Node<bool> _bool;
BinaryTrie.Node<IPAddress> _ipaddress;
[GlobalSetup]
public void Setup()
{
_bool = new BinaryTrie.Node<bool>();
_ipaddress = new BinaryTrie.Node<IPAddress>();
}
[Benchmark]
public bool LookupBoolInlineArray()
{
return BinaryTrie.LookupInlineArray(_bool);
}
[Benchmark]
public bool LookupBoolTernary()
{
return BinaryTrie.LookupTernary(_bool);
}
[Benchmark(Baseline = true)]
public IPAddress LookupIPAddressInlineArray()
{
return BinaryTrie.LookupInlineArray(_ipaddress);
}
[Benchmark]
public IPAddress LookupIPAddressTernary()
{
return BinaryTrie.LookupTernary(_ipaddress);
}
}
} |
Benchmark results on Amd
|
Benchmark results on Arm64
|
Contributor
|
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
Contributor
|
Should we keep #106129 opened if the PR is not merged? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently only the backend liveness pass will DCE calls without side effects when their result is unused. However, unused runtime lookups can end up expanded to control flow that we will be unable to DCE. This teaches the middle-end liveness pass to DCE dead calls as well.
Fix #106129