Skip to content

Implement simple common subexpression elimination.#9

Merged
reventlov merged 3 commits into
google:masterfrom
reventlov:simple_cse_engine
Sep 14, 2020
Merged

Implement simple common subexpression elimination.#9
reventlov merged 3 commits into
google:masterfrom
reventlov:simple_cse_engine

Conversation

@reventlov

Copy link
Copy Markdown
Contributor

This change adds somewhat naive common subexpression elimination in a few places in the generated C++ code. This has little or no effect when C++ compiler optimizations are enabled, however, some users expect to be able to run some code (e.g., tests) with C++ optimizations disabled.

With this change, certain constructs are many orders of magnitude faster in unoptimized builds. The included test (complex_offset_test.cc) goes from >300s (timing out under Bazel) to <1s runtime.

Note that this does not perform any inlining, and the CSE is fairly naive (text-based), so unoptimized builds may still do a lot of repeated work. It also does not add CSE everywhere it could be added; only to places that are likely to have performance issues. Users who care even slightly about performance are still advised to compile with optimizations.

@reventlov reventlov marked this pull request as ready for review September 14, 2020 06:51
@reventlov reventlov merged commit c2bd996 into google:master Sep 14, 2020
@reventlov reventlov deleted the simple_cse_engine branch September 14, 2020 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants