summaryrefslogtreecommitdiff
path: root/src/ir/bits.h
Commit message (Collapse)AuthorAgeFilesLines
* Fix ConstantFieldPropagation signed packed field handling and improve ↵Alon Zakai2024-04-111-0/+24
| | | | | | | | | | | | | | | | Heap2Local's (#6493) CFP already had logic for truncating but not for sign-extending, which this fixes. Use the new helper function in Heap2Local as well. This changes the model there from "truncate on set, sign-extend on get" to "truncate or sign-extend on get". That is both simpler by reusing the same logic as CFP but also more optimal: the idea to truncate on sets made sense since sets are rarer, but if we must then sign-extend on gets then we can end up doing more work overall (as the truncations on sets are not needed if all gets are signed). Found by #6486
* OptimizeInstructions: Use min/max bits in comparisons (#5035)Alon Zakai2022-09-131-0/+11
| | | | | | | When we see e.g. x < y and x has fewer bits set, we can infer a result. Helps #5010. As mentioned there, this is one of the top superoptimizer findings. On j2wasm it ends up removing a few hundred binary operations for example.
* [Wasm GC] RefIs / RefEq / RefTest return a boolean (#4786)Alon Zakai2022-07-081-3/+7
| | | | | | | | | | | | This marks all reference operations that return 0/1 as doing so. This allows various bitwise operations to be optimized on them. This also marks StringEq as a boolean, though we can't test that fully yet as Strings support is wip (no interpreter or other stuff yet). As a driveby this moves emitsBoolean to its own file, and uses it in getMaxBits to avoid redundancy (the redundant code paths now have a WASM_UNREACHABLE).
* Modernize code to C++17 (#3104)Max Graey2021-11-221-6/+2
|
* OptimizeInstructions: Optimize boolean selects (#4147)Alon Zakai2021-09-131-0/+2
| | | | | | | | | | | | If all a select's inputs are boolean, we can sometimes turn the select into an AND or an OR operation, x ? y : 0 => x & y x ? 1 : y => x | y I believe LLVM aggressively canonicalizes to this form. It makes sense to do here too as it is smaller (save the constant 0 or 1). It also allows further optimizations (which is why LLVM does it) but I don't think we have those yet.
* [OptimizeInstructions] Handle post-MVP sign extended operations (#3910)Max Graey2021-06-031-1/+18
| | | fixes part of #3906
* Clean up support/bits.h (#3177)Thomas Lively2020-09-301-5/+5
| | | | | Use overloads instead of templates where applicable and change function names from PascalCase to camelCase. Also puts the functions in the Bits namespace to avoid naming conflicts.
* ir/bits.h cleanups after #2879 (#3156)Alon Zakai2020-09-221-19/+11
| | | | Improve some comments, and remove fast paths that are just optimizations for compile time (code clarity matters more here).
* Fix i64 type checking in getMaxBitsForLocal of DummyLocalInfoProvider (#3150)Max Graey2020-09-211-2/+1
| | | | | The problem existed for a very long time, but since the DummyLocalInfoProvider is almost never used, this did not create problems.
* Implement more cases for getMaxBits (#2879)Max Graey2020-09-171-15/+172
| | | | | | | | | | | | | | | - Complete 64-bit cases in range `AddInt64` ... `ShrSInt64` - `ExtendSInt32` and `ExtendUInt32` for unary cases - For binary cases - `AddInt32` / `AddInt64` - `MulInt32` / `MulInt64` - `RemUInt32` / `RemUInt64` - `RemSInt32` / `RemSInt64` - `DivUInt32` / `DivUInt64` - `DivSInt32` / `DivSInt64` - and more Also more fast paths for some getMaxBits calculations
* Prepare for compound types that are single but not basic (#3046)Daniel Wirtz2020-08-171-2/+2
| | | | | | | | | | | | | | As a follow-up to https://github.com/WebAssembly/binaryen/pull/3012#pullrequestreview-459686171 this PR prepares for the new compound Signature, Struct and Array types that are single but not basic. This includes: * Renames `Type::getSingle` to `Type::getBasic` (NFC). Previously, its name was not representing its implementation (`isSingle` excluded `none` and `unreachable` while `getSingle` didn't, i.e. `getSingle` really was `getBasic`). Note that a hypothetical `Type::getSingle` cannot return `ValueType` anyway (new compound types are single but don't map to `ValueType`), so I figured it's best to skip implementing it until we actually need it. * Marks locations where we are (still) assuming that all single types are basic types, as suggested in https://github.com/WebAssembly/binaryen/pull/3012#discussion_r465356708, but using a macro, so we get useful errors once we start implementing the new types and can quickly traverse the affected locations. The macro is added where * there used to be a `switch (type.getSingle())` or similar that handled any basic type (NFC), but in the future will also have to handle single types that are not basic types. * we are not dealing with `Unary`, `Binary`, `Load`, `Store` or `AtomicXY` instructions, since these don't deal with compound types anyway.
* Refactor getMaxBits() out of OptimizeInstructions and add beginnings of unit ↵Alon Zakai2020-08-041-69/+232
| | | | | | | | | testing for it (#3019) getMaxBits just moves around, no logic is changed. Aside from adding getMaxBits, the change in bits.h is 99% whitespace. helps #2879
* Avoid __popcnt and __popcnt64 intrinsics for MSVC (#2944)Max Graey2020-07-061-3/+3
| | | | We may need to check the CPU ID or something else before using those special things on MSVC. To be safe, avoid them for now.
* [NFC] Enforce use of `Type::` on type names (#2434)Thomas Lively2020-01-071-12/+16
|
* 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.
* clang-tidy braces changes (#2075)Alon Zakai2019-05-011-4/+8
| | | 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-21/+18
| | | 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
* Rename WasmType => Type (#1398)Alon Zakai2018-02-021-1/+1
| | | | * rename WasmType to Type. it's in the wasm:: namespace anyhow, and without Wasm- it fits in better alongside Index, Address, Expression, Module, etc.
* notation change: AST => IR (#1245)Alon Zakai2017-10-241-0/+107
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).