Skip to content

bjornbaverfjord/Boolean-Optimizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Boolean-Optimizer

This program is a superoptimizer for bitwise functions with up to 4 parameters that works by creating a dictionary of the shortest function for each possible truth-table. The code to be optimized has its truth-table calculated and the optimal solution is found in the dictionary by using the truth-table as the key.

Only 65536 such functions exists so they can be precomputed and cached, given enough time and an efficient searcher.

This F# function was not optimised by the F# 3.0 compiler:

let booltest a b = (a ||| b) &&& (~~~ (a &&& b))

It generated this CIL code:

[Ldarg 0; Ldarg 1; Or; Ldarg 0; Ldarg 1; And; Not; And]

Instead of the optimal code found by the optimizer:

[Ldarg 0; Ldarg 1; Xor]


It is 2018 and we have .net core 2.0, things have not improved...

mov edx,ebx
and edx,esi
not edx
mov ecx,ebx
or ecx,esi
and edx,ecx

About

Superoptimizer for bitwise functions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages