-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
JIT: Teach middle-end liveness to DCE dead calls without sideeffects #106183
Closed
Conversation
This file contains 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
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
dotnet-issue-labeler
bot
added
the
area-CodeGen-coreclr
CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
label
Aug 9, 2024
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.
@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
|
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
Should we keep #106129 opened if the PR is not merged? |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
area-CodeGen-coreclr
CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
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