Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e8f9ae6
Add lowering support for conditional nodes
a74nh Mar 22, 2022
e9c0474
Contain conditionals
a74nh Jul 8, 2022
97386b3
Fix formatting
a74nh Jul 11, 2022
1bcd61a
Use AND and CMP nodes
a74nh Jul 12, 2022
7884eca
Fix formatting
a74nh Jul 18, 2022
6d36f9d
Remove LowerNodeCC changes
a74nh Jul 18, 2022
1138fae
Remove asserts & fix variable names
a74nh Jul 19, 2022
d98f9d0
Better contain checks for conditional compares
a74nh Jul 19, 2022
8ef9994
Simpler contained conditions codegen
a74nh Jul 20, 2022
6202894
Remove Conditional Compare nodes
a74nh Jul 18, 2022
c0aba37
Minor cleanups
a74nh Jul 20, 2022
9995881
Generate AND compare chains
a74nh Jul 26, 2022
165060b
Fix unsigned compares && reduce chain check recursion
a74nh Aug 3, 2022
6117333
Add compare chain tests
a74nh Aug 3, 2022
574742f
Review fixes
a74nh Aug 3, 2022
eae824a
Use GenCondition
a74nh Aug 4, 2022
8b282f9
Change CompareChainSize to IsValidCompareChain
a74nh Aug 4, 2022
ce5882d
Move lowering functions to lowerarmarch
a74nh Aug 4, 2022
c548f9f
Formatting fixes
a74nh Aug 4, 2022
df67d67
Fix SELECT issues
a74nh Aug 5, 2022
d1854f8
Fix test output messages.
a74nh Aug 5, 2022
8310017
Better explanations for AND chains
a74nh Aug 5, 2022
e2c8f5d
Compare chains should not contain tst compares
a74nh Aug 8, 2022
25696f1
Don't allow tst compares in codegeneration of compare chains
a74nh Aug 9, 2022
a3d5d0c
Add tests for chains with tst compares
a74nh Aug 9, 2022
cac2740
Don't allow tst compares in lsrabuild of compare chains
a74nh Aug 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests for chains with tst compares
  • Loading branch information
a74nh committed Aug 9, 2022
commit a3d5d0cb20f5ad03a33c6a28ceea7c52d193237c
367 changes: 367 additions & 0 deletions src/tests/JIT/opt/Compares/compareAndTestChains.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,367 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// unit test for compare AND chains that include a binary test.

using System;
using System.Runtime.CompilerServices;

public class ComparisonTestAndTestChains
{
// Using bitwise AND to ensure compare chains are generated.

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Eq_byte_bool(byte a1, bool a2) => (a1 == 10) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Eq_short_bool(short a1, bool a2) => (a1 == 10) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Eq_int_bool(int a1, bool a2) => (a1 == 10) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Eq_long_bool(long a1, bool a2) => (a1 == 10) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Eq_ushort_bool(ushort a1, bool a2) => (a1 == 10) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Eq_uint_bool(uint a1, bool a2) => (a1 == 10) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Eq_ulong_bool(ulong a1, bool a2) => (a1 == 10) & !a2;


[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Ne_byte_bool(byte a1, bool a2) => (a1 != 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Ne_short_bool(short a1, bool a2) => (a1 != 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Ne_int_bool(int a1, bool a2) => (a1 != 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Ne_long_bool(long a1, bool a2) => (a1 != 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Ne_ushort_bool(ushort a1, bool a2) => (a1 != 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Ne_uint_bool(uint a1, bool a2) => (a1 != 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Ne_ulong_bool(ulong a1, bool a2) => (a1 != 5) & !a2;


[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Lt_byte_bool(byte a1, bool a2) => (a1 < 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Lt_short_bool(short a1, bool a2) => (a1 < 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Lt_int_bool(int a1, bool a2) => (a1 < 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Lt_long_bool(long a1, bool a2) => (a1 < 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Lt_ushort_bool(ushort a1, bool a2) => (a1 < 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Lt_uint_bool(uint a1, bool a2) => (a1 < 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Lt_ulong_bool(ulong a1, bool a2) => (a1 < 5) & !a2;


[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Le_byte_bool(byte a1, bool a2) => (a1 <= 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Le_short_bool(short a1, bool a2) => (a1 <= 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Le_int_bool(int a1, bool a2) => (a1 <= 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Le_long_bool(long a1, bool a2) => (a1 <= 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Le_ushort_bool(ushort a1, bool a2) => (a1 <= 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Le_uint_bool(uint a1, bool a2) => (a1 <= 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Le_ulong_bool(ulong a1, bool a2) => (a1 <= 5) & !a2;


[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Gt_byte_bool(byte a1, bool a2) => (a1 > 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Gt_short_bool(short a1, bool a2) => (a1 > 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Gt_int_bool(int a1, bool a2) => (a1 > 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Gt_long_bool(long a1, bool a2) => (a1 > 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Gt_ushort_bool(ushort a1, bool a2) => (a1 > 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Gt_uint_bool(uint a1, bool a2) => (a1 > 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Gt_ulong_bool(ulong a1, bool a2) => (a1 > 5) & !a2;


[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Ge_byte_bool(byte a1, bool a2) => (a1 >= 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Ge_short_bool(short a1, bool a2) => (a1 >= 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Ge_int_bool(int a1, bool a2) => (a1 >= 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Ge_long_bool(long a1, bool a2) => (a1 >= 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Ge_ushort_bool(ushort a1, bool a2) => (a1 >= 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Ge_uint_bool(uint a1, bool a2) => (a1 >= 5) & !a2;

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool Ge_ulong_bool(ulong a1, bool a2) => (a1 >= 5) & !a2;


[MethodImpl(MethodImplOptions.NoInlining)]
public static int Main()
{
if (!Eq_byte_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Eq_byte_bool(10, false) failed");
return 101;
}
if (!Eq_short_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Eq_short_bool(10, false) failed");
return 101;
}
if (!Eq_int_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Eq_int_bool(10, false) failed");
return 101;
}
if (!Eq_long_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Eq_long_bool(10, false) failed");
return 101;
}
if (!Eq_ushort_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Eq_ushort_bool(10, false) failed");
return 101;
}
if (!Eq_uint_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Eq_uint_bool(10, false) failed");
return 101;
}
if (!Eq_ulong_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Eq_ulong_bool(10, false) failed");
return 101;
}

if (!Ne_byte_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Ne_byte_bool(10, false) failed");
return 101;
}
if (!Ne_short_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Ne_short_bool(10, false) failed");
return 101;
}
if (!Ne_int_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Ne_int_bool(10, false) failed");
return 101;
}
if (!Ne_long_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Ne_long_bool(10, false) failed");
return 101;
}
if (!Ne_ushort_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Ne_ushort_bool(10, false) failed");
return 101;
}
if (!Ne_uint_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Ne_uint_bool(10, false) failed");
return 101;
}
if (!Ne_ulong_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Ne_ulong_bool(10, false) failed");
return 101;
}

if (!Lt_byte_bool(3, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Lt_byte_bool(3, false) failed");
return 101;
}
if (!Lt_short_bool(3, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Lt_short_bool(3, false) failed");
return 101;
}
if (!Lt_int_bool(3, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Lt_int_bool(3, false) failed");
return 101;
}
if (!Lt_long_bool(3, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Lt_long_bool(3, false) failed");
return 101;
}
if (!Lt_ushort_bool(3, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Lt_ushort_bool(3, false) failed");
return 101;
}
if (!Lt_uint_bool(3, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Lt_uint_bool(3, false) failed");
return 101;
}
if (!Lt_ulong_bool(3, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Lt_ulong_bool(3, false) failed");
return 101;
}

if (!Le_byte_bool(3, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Le_byte_bool(3, false) failed");
return 101;
}
if (!Le_short_bool(3, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Le_short_bool(3, false) failed");
return 101;
}
if (!Le_int_bool(3, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Le_int_bool(3, false) failed");
return 101;
}
if (!Le_long_bool(3, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Le_long_bool(3, false) failed");
return 101;
}
if (!Le_ushort_bool(3, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Le_ushort_bool(3, false) failed");
return 101;
}
if (!Le_uint_bool(3, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Le_uint_bool(3, false) failed");
return 101;
}
if (!Le_ulong_bool(3, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Le_ulong_bool(3, false) failed");
return 101;
}

if (!Gt_byte_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Gt_byte_bool(10, false) failed");
return 101;
}
if (!Gt_short_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Gt_short_bool(10, false) failed");
return 101;
}
if (!Gt_int_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Gt_int_bool(10, false) failed");
return 101;
}
if (!Gt_long_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Gt_long_bool(10, false) failed");
return 101;
}
if (!Gt_ushort_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Gt_ushort_bool(10, false) failed");
return 101;
}
if (!Gt_uint_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Gt_uint_bool(10, false) failed");
return 101;
}
if (!Gt_ulong_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Gt_ulong_bool(10, false) failed");
return 101;
}

if (!Ge_byte_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Ge_byte_bool(10, false) failed");
return 101;
}
if (!Ge_short_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Ge_short_bool(10, false) failed");
return 101;
}
if (!Ge_int_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Ge_int_bool(10, false) failed");
return 101;
}
if (!Ge_long_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Ge_long_bool(10, false) failed");
return 101;
}
if (!Ge_ushort_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Ge_ushort_bool(10, false) failed");
return 101;
}
if (!Ge_uint_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Ge_uint_bool(10, false) failed");
return 101;
}
if (!Ge_ulong_bool(10, false))
{
Console.WriteLine("ComparisonTestAndTestChains:Le_ulong_bool(10, false) failed");
return 101;
}

Console.WriteLine("PASSED");
return 100;
}
}
12 changes: 12 additions & 0 deletions src/tests/JIT/opt/Compares/compareAndTestChains.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>PdbOnly</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>