Optimize C++ Backend for Conditional Fields #234
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change significantly optimizes the generated C++ code for
structures utilizing conditional fields.
Key optimizations include:
frequently used subexpressions (e.g., tag reads) within Ok(),
Equals(), and UncheckedEquals() methods.
by a second pass that caches repeated expressions in local
variables while inlining unique ones.
performance improvements and reduced stack usage for unique
conditions.
Performance Impact (on testdata/many_conditionals.emb with 10,000
iterations x 100 tags):
bytes for many_conditionals_benchmark with -c opt).
Additional updates:
golden tests, resolving an issue with no_enum_traits_golden_test.
(compiler/back_end/cpp/testcode/many_conditionals_benchmark.cc)
were added to verify performance.