-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimized Division by Constant (#1139)
* - WIP * - WIP * - Updated nuget packages * - Updated nuget packages * - Updated nuget packages * - Updated nuget packages * - Nice disconnect * - Division by Constant * - WIP * - Optimization for Division by a constant - Also bug fixes * - Optimization for Division by a constant - Also fixed some bugs * - Optimization for Division by a constant - Also fixed some bugs * - Optimization for Division by a constant - Also fixed some bugs * - Optimization for Division by a constant - Also fixed some bugs * - WIP * - WIP * - Minor refactoring * - Fixes * - Fixes * - Fixes * - Additions * - Additions
- Loading branch information
Showing
74 changed files
with
855 additions
and
276 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
|
||
<PropertyGroup> | ||
<PropertyGroup> | ||
<OutputPath>../../bin</OutputPath> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<LangVersion>11.0</LangVersion> | ||
<Nullable>enable</Nullable> | ||
<Nullable>disable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<!-- <WarningsAsErrors>nullable</WarningsAsErrors>--> | ||
<!-- <WarningsAsErrors>nullable</WarningsAsErrors>--> | ||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> | ||
<CodeAnalysisRuleSet>../Common.ruleset</CodeAnalysisRuleSet> | ||
<Company>MOSA Project</Company> | ||
<Copyright>Copyright © MOSA Project 2023</Copyright> | ||
<AssemblyVersion>2.5.0.0</AssemblyVersion> | ||
</PropertyGroup> | ||
|
||
</PropertyGroup> | ||
</Project> |
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
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
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
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
51 changes: 0 additions & 51 deletions
51
Source/Mosa.Compiler.Common.xUnit/DivisionMagicNumberTests.cs
This file was deleted.
Oops, something went wrong.
77 changes: 77 additions & 0 deletions
77
Source/Mosa.Compiler.Common.xUnit/DivisionTwiddlingTests.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright (c) MOSA Project. Licensed under the New BSD License. | ||
|
||
using System.Diagnostics; | ||
using Xunit; | ||
|
||
namespace Mosa.Compiler.Common.xUnit; | ||
|
||
public class DivisionTwiddlingTests | ||
{ | ||
[Fact] | ||
public static void SignedMagic_3() | ||
{ | ||
var (M, s) = DivisionTwiddling.GetMagicNumber(3); | ||
Debug.Assert(M == 0x55555556); | ||
Debug.Assert(s == 0); | ||
} | ||
|
||
[Fact] | ||
public static void SignedMagic_7() | ||
{ | ||
var (M, s) = DivisionTwiddling.GetMagicNumber(7); | ||
Debug.Assert(M == 0x92492493); | ||
Debug.Assert(s == 2); | ||
} | ||
|
||
[Fact] | ||
public static void UnsignedMagic_3() | ||
{ | ||
var (M, s, a) = DivisionTwiddling.GetMagicNumber(3u); | ||
Debug.Assert(M == 0xAAAAAAAB); | ||
Debug.Assert(s == 1); | ||
Debug.Assert(!a); | ||
} | ||
|
||
[Fact] | ||
public static void UnsignedMagic_7() | ||
{ | ||
var (M, s, a) = DivisionTwiddling.GetMagicNumber(7u); | ||
Debug.Assert(M == 0x24924925); | ||
Debug.Assert(s == 3); | ||
Debug.Assert(a); | ||
} | ||
|
||
//[Fact] | ||
//public static void UnsignedMagic_11() | ||
//{ | ||
// var result = DivisionMagicNumber.GetMagicNumber(13u); | ||
// Debug.Assert(result.M + result.a + result.s == ((uint)-1171354717) + 0 + 3); | ||
//} | ||
|
||
[Fact] | ||
public static void UnsignedMagic_13() | ||
{ | ||
var (M, s, a) = DivisionTwiddling.GetMagicNumber(13u); | ||
Debug.Assert(M == 1321528399); | ||
Debug.Assert(s == 2); | ||
Debug.Assert(!a); | ||
} | ||
|
||
[Fact] | ||
public static void UnsignedMagic2_3() | ||
{ | ||
var (M, s, a) = DivisionTwiddling.GetMagicNumber(3u); | ||
Debug.Assert(M == 0xAAAAAAAB); | ||
Debug.Assert(s == 1); | ||
Debug.Assert(!a); | ||
} | ||
|
||
[Fact] | ||
public static void UnsignedMagic2_7() | ||
{ | ||
var (M, s, a) = DivisionTwiddling.GetMagicNumber(7u); | ||
Debug.Assert(M == 0x24924925); | ||
Debug.Assert(s == 3); | ||
Debug.Assert(a); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.