summaryrefslogtreecommitdiff
path: root/src/passes/OptimizeForJS.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Refactor interaction between Pass and PassRunner (#5093)Thomas Lively2022-09-301-1/+3
| | | | | | | | | | | | | | Previously only WalkerPasses had access to the `getPassRunner` and `getPassOptions` methods. Move those methods to `Pass` so all passes can use them. As a result, the `PassRunner` passed to `Pass::run` and `Pass::runOnFunction` is no longer necessary, so remove it. Also update `Pass::create` to return a unique_ptr, which is more efficient than having it return a raw pointer only to have the `PassRunner` wrap that raw pointer in a `unique_ptr`. Delete the unused template `PassRunner::getLast()`, which looks like it was intended to enable retrieving previous analyses and has been in the code base since 2015 but is not implemented anywhere.
* [OptimizeForJS] Fix use of localized variable in popcnt(x) == 1 rule (#4057)Max Graey2021-08-051-3/+1
| | | | Localizer may have added a new tee and a local, and we should apply the tee in the right place.
* [OptimizeForJS] Refactor rewritePopcntEqualOne (#4050)Max Graey2021-08-031-26/+8
|
* [JS] Add a new OptimizeForJS pass (#4033)Max Graey2021-08-021-0/+92
Add a new OptimizeForJS pass which contains rewriting rules specific to JavaScript. LLVM usually lowers x != 0 && (x & (x - 1)) == 0 (isPowerOf2) to popcnt(x) == 1 which is ok for wasm and other targets but is quite expensive for JavaScript. In this PR we lower the popcnt pattern back to the isPowerOf2 pattern.