summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Graey <maxgraey@gmail.com>2020-10-01 23:57:58 +0300
committerGitHub <noreply@github.com>2020-10-01 13:57:58 -0700
commitf703a3a3c9021e1ae2cb009a37786210d3fcf870 (patch)
treeef1508e7fa7264279ffae6c5ea005e509f829d58 /src
parent7549fa413b6e3a8eba1f8cfba1c24f01692cfb5b (diff)
downloadbinaryen-f703a3a3c9021e1ae2cb009a37786210d3fcf870.tar.gz
binaryen-f703a3a3c9021e1ae2cb009a37786210d3fcf870.tar.bz2
binaryen-f703a3a3c9021e1ae2cb009a37786210d3fcf870.zip
Add comment about signed => unsigned lowering (#3187)
Diffstat (limited to 'src')
-rw-r--r--src/passes/OptimizeInstructions.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp
index dc38933a6..3b7a9dc6d 100644
--- a/src/passes/OptimizeInstructions.cpp
+++ b/src/passes/OptimizeInstructions.cpp
@@ -524,6 +524,10 @@ struct OptimizeInstructions
if (right->type == Type::i32) {
BinaryOp op;
int32_t c = right->value.geti32();
+ // First, try to lower signed operations to unsigned if that is
+ // possible. Some unsigned operations like div_u or rem_u are usually
+ // faster on VMs. Also this opens more possibilities for further
+ // simplifications afterwards.
if (c >= 0 &&
(op = makeUnsignedBinaryOp(binary->op)) != InvalidBinary &&
Bits::getMaxBits(binary->left, this) <= 31) {
@@ -545,6 +549,7 @@ struct OptimizeInstructions
if (right->type == Type::i64) {
BinaryOp op;
int64_t c = right->value.geti64();
+ // See description above for Type::i32
if (c >= 0 &&
(op = makeUnsignedBinaryOp(binary->op)) != InvalidBinary &&
Bits::getMaxBits(binary->left, this) <= 63) {