summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/passes/OptimizeInstructions.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp
index de96e418e..3a344ff88 100644
--- a/src/passes/OptimizeInstructions.cpp
+++ b/src/passes/OptimizeInstructions.cpp
@@ -1447,8 +1447,7 @@ private:
}
{
double value;
- if (fastMath &&
- matches(curr, binary(Abstract::Sub, any(), fval(&value))) &&
+ if (matches(curr, binary(Abstract::Sub, any(), fval(&value))) &&
value == 0.0) {
// x - (-0.0) ==> x + 0.0
if (std::signbit(value)) {
@@ -1470,6 +1469,10 @@ private:
return curr->left;
}
}
+ // x * -1.0 ==> -x
+ if (fastMath && matches(curr, binary(Abstract::Mul, any(), fval(-1.0)))) {
+ return builder.makeUnary(Abstract::getUnary(type, Abstract::Neg), left);
+ }
if (matches(curr, binary(Abstract::Mul, any(&left), constant(1))) ||
matches(curr, binary(Abstract::DivS, any(&left), constant(1))) ||
matches(curr, binary(Abstract::DivU, any(&left), constant(1)))) {