WIP: optimize cmp_eq of enums #78

Draft
programmerjake wants to merge 6 commits from programmerjake/fayalite:cmp_eq-opts into master

The plan is to optimize cmp_eq of enums by:

  • adding a ops::StructuralEq operation that has a assume_padding_is_zeroed flag so comparison of enums can lower to just a simple integer compare
  • and then to modify simplify_enums to deduce when it can set assume_padding_is_zeroed while retaining comparison semantics by having a fixed-point connection graph algorithm to find all places that could generate enum values with padding that isn't zero.
    (this includes cast_bits_to and external inputs, when enums are lowered to integers by simplify_enums).

DONE:

  • add deduction pass
  • make sure StructuralEq isn't generated when it can't be used (e.g. customized comparison, or when the types aren't equal, or when the type contains a SimOnly)
  • Fix simulator to properly handle StructuralEq of enums.

TODO:

  • optimize deduce_structural_eq_flags to not have a O(n^2) algorithm.
The plan is to optimize cmp_eq of enums by: * adding a `ops::StructuralEq` operation that has a `assume_padding_is_zeroed` flag so comparison of enums can lower to just a simple integer compare * and then to modify `simplify_enums` to deduce when it can set `assume_padding_is_zeroed` while retaining comparison semantics by having a fixed-point connection graph algorithm to find all places that could generate enum values with padding that isn't zero. (this includes `cast_bits_to` and external inputs, when enums are lowered to integers by `simplify_enums`). DONE: * add deduction pass * make sure `StructuralEq` isn't generated when it can't be used (e.g. customized comparison, or when the types aren't equal, or when the type contains a `SimOnly`) * Fix simulator to properly handle StructuralEq of enums. TODO: * optimize `deduce_structural_eq_flags` to not have a O(n^2) algorithm.
programmerjake added 1 commit 2026-06-09 07:19:33 +00:00
fayalite::expr::ops: add and automatically generate ops::StructuralEq
All checks were successful
/ test (pull_request) Successful in 4m20s
80a11ec1c2
programmerjake force-pushed cmp_eq-opts from 80a11ec1c2 to af0f1f608a 2026-06-10 08:25:14 +00:00 Compare
programmerjake force-pushed cmp_eq-opts from af0f1f608a to 4bd6db3de8 2026-06-11 08:27:09 +00:00 Compare
programmerjake added 1 commit 2026-06-11 08:57:03 +00:00
WIP: fix simulator StructuralEq of enums
Some checks failed
/ test (pull_request) Failing after 1m25s
30ffd009f6
programmerjake added 2 commits 2026-06-12 03:56:50 +00:00
programmerjake added 1 commit 2026-06-13 02:59:10 +00:00
add BoolFixedPointSolver
All checks were successful
/ test (pull_request) Successful in 4m44s
b0e7873a17
All checks were successful
/ test (pull_request) Successful in 4m44s
Required
Details
This pull request is marked as a work in progress.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u cmp_eq-opts:programmerjake-cmp_eq-opts
git checkout programmerjake-cmp_eq-opts
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: libre-chip/fayalite#78
No description provided.