summaryrefslogtreecommitdiff
path: root/src/passes/OptimizeInstructions.cpp
diff options
context:
space:
mode:
authorMax Graey <maxgraey@gmail.com>2022-09-21 19:24:56 +0300
committerGitHub <noreply@github.com>2022-09-21 16:24:56 +0000
commit8f385b04afd6e968fa83dfade7f7858ba0824e37 (patch)
tree1ed199b68071e7f49c9f72df4b8fb046e8650b99 /src/passes/OptimizeInstructions.cpp
parent7fb6cfb4e0ef3af329cb6481407f9b167b4ac491 (diff)
downloadbinaryen-8f385b04afd6e968fa83dfade7f7858ba0824e37.tar.gz
binaryen-8f385b04afd6e968fa83dfade7f7858ba0824e37.tar.bz2
binaryen-8f385b04afd6e968fa83dfade7f7858ba0824e37.zip
[OptimizeInstruction] Prevent reordering for rule in #5034 (#5066)
Diffstat (limited to 'src/passes/OptimizeInstructions.cpp')
-rw-r--r--src/passes/OptimizeInstructions.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp
index 2f1b6b6a4..e9cf3baaa 100644
--- a/src/passes/OptimizeInstructions.cpp
+++ b/src/passes/OptimizeInstructions.cpp
@@ -416,8 +416,9 @@ struct OptimizeInstructions
{
// -x + y ==> y - x
// where x, y are floating points
- Expression* x;
- if (matches(curr, binary(Add, unary(Neg, any(&x)), any()))) {
+ Expression *x, *y;
+ if (matches(curr, binary(Add, unary(Neg, any(&x)), any(&y))) &&
+ canReorder(x, y)) {
curr->op = Abstract::getBinary(curr->type, Sub);
curr->left = x;
std::swap(curr->left, curr->right);