Skip to content

Instantly share code, notes, and snippets.

@jfrijters
jfrijters / Avx2Life16x16.cs
Last active May 3, 2020 09:02
.NET Core 3.1 AVX2 16x16 life implementation
using System;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
namespace CoreConsoleApp1
{
static class Program
{
static void Main()
{
public readonly struct NullableDouble
{
private readonly long value;
private NullableDouble(double value)
{
var bits = BitConverter.DoubleToInt64Bits(value);
if (bits == -1)
{
// the double passed in was NaN, but the pattern equals the pattern we use for NULL values,
@jfrijters
jfrijters / gist:10151709
Created April 8, 2014 16:27
typeof(Foo).GetMethod("Foo") optimization
diff --git a/Src/Compilers/CSharp/Source/Lowering/LocalRewriter/LocalRewriter_Call.cs b/Src/Compilers/CSharp/Source/Lowering/LocalRewriter/LocalRewriter_Call.cs
index d356dec..3ad67f5 100644
--- a/Src/Compilers/CSharp/Source/Lowering/LocalRewriter/LocalRewriter_Call.cs
+++ b/Src/Compilers/CSharp/Source/Lowering/LocalRewriter/LocalRewriter_Call.cs
@@ -130,6 +130,35 @@ namespace Microsoft.CodeAnalysis.CSharp
{
Debug.Assert(node != null);
+ if (node.ReceiverOpt is BoundTypeOfOperator && node.Method.Name == "GetMethod" && !node.Method.IsExtensionMethod)
+ {