optimize cmp_eq of enums #78

Merged
programmerjake merged 7 commits from programmerjake/fayalite:cmp_eq-opts into master 2026-06-14 08:38:43 +00:00

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.
  • 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. * 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
programmerjake added 1 commit 2026-06-14 08:33:20 +00:00
module::transform::deduce_structural_eq_flags: rewrite to use BoolFixedPointSolver for a massive speedup on large inputs
All checks were successful
/ test (pull_request) Successful in 4m43s
/ test (push) Successful in 5m16s
7ddb4780fa
programmerjake changed title from WIP: optimize cmp_eq of enums to optimize cmp_eq of enums 2026-06-14 08:38:33 +00:00
programmerjake merged commit 7ddb4780fa into master 2026-06-14 08:38:43 +00:00
programmerjake deleted branch cmp_eq-opts 2026-06-14 08:38:43 +00:00
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.