diff options
author | Max Graey <maxgraey@gmail.com> | 2022-08-02 22:29:53 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-02 12:29:53 -0700 |
commit | deb40b7cd6d02adc14c09782b2211e2d68c612b1 (patch) | |
tree | c9b41654a100f288576c7237bfac7f058bfc09f9 /src/ir/abstract.h | |
parent | 03b85abf184210d7a2aecac3e71659d7a3ee2eff (diff) | |
download | binaryen-deb40b7cd6d02adc14c09782b2211e2d68c612b1.tar.gz binaryen-deb40b7cd6d02adc14c09782b2211e2d68c612b1.tar.bz2 binaryen-deb40b7cd6d02adc14c09782b2211e2d68c612b1.zip |
[Optimize Instructions] Refactor squared rules (#4840)
+ Move these rules to separate function;
+ Refactor them to use matches;
+ Add comments;
+ Handle rotational shifts as well;
+ Handle overflows for `<<`, `>>`, `>>>` shifts;
+ Add mixed rotate rules:
```rust
rotl(rotr(x, C1), C2) => rotr(x, C1 - C2)
rotr(rotl(x, C1), C2) => rotl(x, C1 - C2)
```
Diffstat (limited to 'src/ir/abstract.h')
-rw-r--r-- | src/ir/abstract.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ir/abstract.h b/src/ir/abstract.h index feac9b50d..0cfeeea77 100644 --- a/src/ir/abstract.h +++ b/src/ir/abstract.h @@ -59,13 +59,17 @@ enum Op { GeU }; -inline bool hasAnyShift(BinaryOp op) { - return op == ShlInt32 || op == ShrSInt32 || op == ShrUInt32 || - op == RotLInt32 || op == RotRInt32 || op == ShlInt64 || - op == ShrSInt64 || op == ShrUInt64 || op == RotLInt64 || +inline bool hasAnyRotateShift(BinaryOp op) { + return op == RotLInt32 || op == RotRInt32 || op == RotLInt64 || op == RotRInt64; } +inline bool hasAnyShift(BinaryOp op) { + return hasAnyRotateShift(op) || op == ShlInt32 || op == ShrSInt32 || + op == ShrUInt32 || op == ShlInt64 || op == ShrSInt64 || + op == ShrUInt64; +} + inline bool hasAnyReinterpret(UnaryOp op) { return op == ReinterpretInt32 || op == ReinterpretInt64 || op == ReinterpretFloat32 || op == ReinterpretFloat64; |