From 8f385b04afd6e968fa83dfade7f7858ba0824e37 Mon Sep 17 00:00:00 2001 From: Max Graey Date: Wed, 21 Sep 2022 19:24:56 +0300 Subject: [OptimizeInstruction] Prevent reordering for rule in #5034 (#5066) --- src/passes/OptimizeInstructions.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') 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); -- cgit v1.2.3