summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/passes/OptimizeInstructions.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp
index 0ce1f5f95..b11df3276 100644
--- a/src/passes/OptimizeInstructions.cpp
+++ b/src/passes/OptimizeInstructions.cpp
@@ -346,6 +346,7 @@ struct OptimizeInstructions
{
// x <<>> (C & (31 | 63)) ==> x <<>> C'
// x <<>> (y & (31 | 63)) ==> x <<>> y
+ // x <<>> (y & (32 | 64)) ==> x
// where '<<>>':
// '<<', '>>', '>>>'. 'rotl' or 'rotr'
BinaryOp op;
@@ -375,6 +376,13 @@ struct OptimizeInstructions
curr->cast<Binary>()->right = y;
return curr;
}
+ // i32(x) <<>> (y & 32) ==> x
+ // i64(x) <<>> (y & 64) ==> x
+ if (((c->type == Type::i32 && (c->value.geti32() & 31) == 0) ||
+ (c->type == Type::i64 && (c->value.geti64() & 63LL) == 0LL)) &&
+ !effects(y).hasSideEffects()) {
+ return x;
+ }
}
}
{