diff options
author | Max Graey <maxgraey@gmail.com> | 2020-10-01 23:57:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-01 13:57:58 -0700 |
commit | f703a3a3c9021e1ae2cb009a37786210d3fcf870 (patch) | |
tree | ef1508e7fa7264279ffae6c5ea005e509f829d58 /src | |
parent | 7549fa413b6e3a8eba1f8cfba1c24f01692cfb5b (diff) | |
download | binaryen-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.cpp | 5 |
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) { |