summaryrefslogtreecommitdiff
path: root/src/passes/OptimizeInstructions.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove implicit conversion operators from Type (#2577)Thomas Lively2020-01-081-3/+3
| | | | | | | | | | * Remove implicit conversion operators from Type Now types must be explicitly converted to uint32_t with Type::getID or to ValueType with Type::getVT. This fixes #2572 for switches that use Type::getVT. * getVT => getSingle
* [NFC] Enforce use of `Type::` on type names (#2434)Thomas Lively2020-01-071-18/+18
|
* Add support for reference types proposal (#2451)Heejin Ahn2019-12-301-3/+3
| | | | | | | | | | | | This adds support for the reference type proposal. This includes support for all reference types (`anyref`, `funcref`(=`anyfunc`), and `nullref`) and four new instructions: `ref.null`, `ref.is_null`, `ref.func`, and new typed `select`. This also adds subtype relationship support between reference types. This does not include table instructions yet. This also does not include wasm2js support. Fixes #2444 and fixes #2447.
* Add string parameter to WASM_UNREACHABLE (#2499)Sam Clegg2019-12-051-2/+2
| | | | | This works more like llvm's unreachable handler in that is preserves information even in release builds.
* Multivalue type creation and inspection (#2459)Thomas Lively2019-11-221-5/+5
| | | | | | | | | | | | | Adds the ability to create multivalue types from vectors of concrete value types. All types are transparently interned, so their representation is still a single uint32_t. Types can be extracted into vectors of their component parts, and all the single value types expand into vectors containing themselves. Multivalue types are not yet used in the IR, but their creation and inspection functionality is exposed and tested in the C and JS APIs. Also makes common type predicates methods of Type and improves the ergonomics of type printing.
* OptimizeInstructions: Eq64 of 0 => Eqz64 (#2421)Alon Zakai2019-11-041-0/+2
| | | Fixes #2417
* Optimize select fallthrough values (#2220)Alon Zakai2019-07-111-0/+4
| | | This became noticeable after #2216 which led to some eqz eqz pairs in the test suite.
* Fix comparison signedness errors in optimizeMemoryAccess() (#2211)Sean Stangl2019-07-101-3/+3
|
* Un-recursify OptimizeInstructions::optimizeAddedConstants (#2157)Alon Zakai2019-05-311-16/+27
| | | | | This helps avoid issues with smaller stack sizes on some OSes. Should fix the last Mac test failure on emscripten-releases CI (other.test_js_function_names_are_minified, which happens to have massively-nested additions of constants).
* Reflect instruction renaming in code (#2128)Heejin Ahn2019-05-211-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Reflected new renamed instruction names in code and tests: - `get_local` -> `local.get` - `set_local` -> `local.set` - `tee_local` -> `local.tee` - `get_global` -> `global.get` - `set_global` -> `global.set` - `current_memory` -> `memory.size` - `grow_memory` -> `memory.grow` - Removed APIs related to old instruction names in Binaryen.js and added APIs with new names if they are missing. - Renamed `typedef SortedVector LocalSet` to `SetsOfLocals` to prevent name clashes. - Resolved several TODO renaming items in wasm-binary.h: - `TableSwitch` -> `BrTable` - `I32ConvertI64` -> `I32WrapI64` - `I64STruncI32` -> `I64SExtendI32` - `I64UTruncI32` -> `I64UExtendI32` - `F32ConvertF64` -> `F32DemoteI64` - `F64ConvertF32` -> `F64PromoteF32` - Renamed `BinaryenGetFeatures` and `BinaryenSetFeatures` to `BinaryenModuleGetFeatures` and `BinaryenModuleSetFeatures` for consistency.
* clang-tidy braces changes (#2075)Alon Zakai2019-05-011-18/+36
| | | Applies the changes in #2065, and temprarily disables the hook since it's too slow to run on a change this large. We should re-enable it in a later commit.
* Apply format changes from #2048 (#2059)Alon Zakai2019-04-261-212/+391
| | | Mass change to apply clang-format to everything. We are applying this in a PR by me so the (git) blame is all mine ;) but @aheejin did all the work to get clang-format set up and all the manual work to tidy up some things to make the output nicer in #2048
* avoid signed overflow undefined behavior in OptimizeInstructions constant ↵Alon Zakai2019-04-091-2/+2
| | | | computations (#1990)
* Massive renaming (#1855)Thomas Lively2019-01-071-1/+1
| | | | | | Automated renaming according to https://github.com/WebAssembly/spec/issues/884#issuecomment-426433329.
* Do not attempt to optimize v128s yet (#1834)Thomas Lively2018-12-181-12/+15
| | | Until the `Abstract` interface gains a notion of SIMD lanes, these optimizations will crash on v128 types.
* SIMD (#1820)Thomas Lively2018-12-131-4/+4
| | | | | | | | | Implement and test the following functionality for SIMD. - Parsing and printing - Assembling and disassembling - Interpretation - C API - JS API
* Start to implement #1764 (#1776)Alon Zakai2018-11-281-0/+34
| | | | | | This adds a first instance of the rules discussed in #1764 , specifically, x == y || x > y => x >= y
* Stricter Canonicalization (#1774)Alon Zakai2018-11-271-18/+69
| | | In OptimizeInstructions we canonicalized a const on the right side. This PR adds further canonicalization, of a get to the right, and of sorting by binary and unary op ids. This guarantees fixed orders for small combinations of instructions that can then be pattern-matched in a simple way in future PRs.
* Fix a bug with (add (sub 0 X) Y) => (sub Y X) (#1727)Alon Zakai2018-11-071-2/+19
| | | | | We need to verify that the reordering is valid if there are side effects. Original bug report: https://groups.google.com/forum/?nomobile=true#!topic/emscripten-discuss/HIlGf8o2Ato
* Unify imported and non-imported things (#1678)Alon Zakai2018-09-191-126/+0
| | | | | | | | | | | | | | Fixes #1649 This moves us to a single object for functions, which can be imported or nor, and likewise for globals (as a result, GetGlobals do not need to check if the global is imported or not, etc.). All imported things now inherit from Importable, which has the module and base of the import, and if they are set then it is an import. For convenient iteration, there are a few helpers like ModuleUtils::iterDefinedGlobals(wasm, [&](Global* global) { .. use global .. }); as often iteration only cares about imported or defined (non-imported) things.
* Improve getFallthrough (#1643)Alon Zakai2018-08-271-18/+2
| | | | | That method looks through tee_locals and other operations that receive a value and let it flow through them, like a block's final value, etc. It just handled a few such operations, with this PR all of them should be handled. Also refactor it out of the OptimizeInstructions pass as I think it may be useful for propagating returned constants.
* Fix MSVC warnings when compiling the binaryen target (#1535)Daniel Wirtz2018-05-091-1/+1
|
* optimize selects of constant conditions (#1516)Alon Zakai2018-04-271-0/+20
|
* More math opts (#1507)Alon Zakai2018-04-111-3/+20
| | | `xor` of 0, `and` and `or` of -1
* More simple math opts (#1506)Alon Zakai2018-04-111-2/+72
| | | | | * Optimize shifts of 0. * Optimize f(x, x) for various f (e.g., x & x => x).
* Some simple integer math opts (#1504)Alon Zakai2018-04-111-15/+121
| | | | | | | | | Stuff like x + 5 != 2 => x != -3. Also some cleanups of utility functions I noticed while writing this, isTypeFloat => isFloatType. Inspired by https://github.com/golang/go/blob/master/src/cmd/compile/internal/ssa/gen/generic.rules
* fix some comment typos (#1425)Nathan Froyd2018-02-141-2/+2
|
* More simple math opts (#1414)Alon Zakai2018-02-141-2/+45
| | | | | | | | * optimize more simple math operations: mul of 0, or of 0, and of 0, mul of 1, mul of a power of 2, urem of a power of 2 * fix asm2wasm callImport parsing: the optimizer may get rid of the added offset to a function table * update js builds
* Rename WasmType => Type (#1398)Alon Zakai2018-02-021-3/+3
| | | | * rename WasmType to Type. it's in the wasm:: namespace anyhow, and without Wasm- it fits in better alongside Index, Address, Expression, Module, etc.
* optimize out 0-x, a zero only used to negate an int, when possible (#1365)Alon Zakai2018-01-171-1/+37
|
* De-morgan's "and" law (#1297)Alon Zakai2017-11-301-0/+26
| | | | | (eqz X) and (eqz Y) === eqz (X or Y) Normally de-morgan's laws apply only to boolean vars, but for the and (but not or or xor) version, it works in all cases (both sides are true iff X and Y have all zero bits).
* add i64_atomics_* support to asm2wasm (#1262)Alon Zakai2017-11-141-1/+2
| | | | | | * add i64_atomics_* support to asm2wasm * OptimizeInstructions: atomic loads can't be signed
* notation change: AST => IR (#1245)Alon Zakai2017-10-241-7/+7
| | | The IR is indeed a tree, but not an "abstract syntax tree" since there is no language for which it is the syntax (except in the most trivial and meaningless sense).
* only look at the |signed| field of loads if it is relevant (#1235)Alon Zakai2017-10-231-2/+4
|
* Add a superclass typedef to WalkerPass to simplify overrides (#1211)jgravelle-google2017-10-041-1/+1
|
* fix regression from 45d88e3ef5f895b2fde77e3588f84d66e67bdd88 - left may not ↵Alon Zakai2017-10-021-1/+1
| | | | exist, need to return curr->left, after that change (#1207)
* fix optimize-instructions handling of shifts by a zero or of a zero when ↵Alon Zakai2017-10-021-2/+3
| | | | combining added constants (#1206)
* Merge pull request #1175 from WebAssembly/fuzzAlon Zakai2017-09-101-6/+23
|\ | | | | Fuzzer improvements + fixes
| * when if arms are identical, merging them may change the type of the if, if ↵Alon Zakai2017-09-061-6/+23
| | | | | | | | it has a forced type
* | Add support for sign-extension operators from threading proposal (#1167)Derek Schuff2017-09-061-0/+2
|/ | | These are not atomic operations, but are added with the atomic operations to keep from having to define atomic versions of all the sign-extending loads (an atomic zero-extending load + signext operation can be used instead).
* Return to more structured type rules for block and if (#1148)Alon Zakai2017-09-051-0/+8
| | | | | | | | * if a block has a concrete final element (or a break with a value), then even if it has an unreachable child, keep it with that concrete type. this means we no longe allow the silly case of a block with an unreachable in the middle and a concrete as the final element while the block is unreachable - after this change, the block would have the type of the final element * if an if has a concrete element in one arm, make it have that type as a result, even if the if condition is unreachable, to parallel block * make type rules for brs and switches simpler, ignore whether they are reachable or not. whether they are dead code should not affect how they influence other types in our IR.
* fix off-by-one error in clz/ctz/popcount used bits computationAlon Zakai2017-08-011-2/+2
|
* use effective shifts in more places in optimize-instructionsAlon Zakai (kripken)2017-08-011-2/+2
|
* review commentsAlon Zakai (kripken)2017-07-311-5/+5
|
* handle squared shifts of an unreachableAlon Zakai (kripken)2017-07-311-2/+2
|
* fix optimizing two shifts into one; if the number of effective shifts ↵Alon Zakai (kripken)2017-07-301-3/+11
| | | | overflows, it is not vali to just add them
* do not swap elements in conditionalizeExpensiveOnBitwise if they invalidate ↵Alon Zakai (kripken)2017-07-291-6/+9
| | | | each other - it is not enough to check side effects, we must check the interaction as well
* refactor effective shift size computationAlon Zakai2017-07-291-3/+3
|
* fix shl shift computation in getMaxBitsAlon Zakai2017-07-291-1/+1
|
* fix shift computation in getMaxBits - in wasm only the lower 5 bits matter ↵Alon Zakai2017-07-291-2/+2
| | | | for a 32-bit shift