summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_simplifier.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/optimizing/instruction_simplifier.cc')
-rw-r--r--compiler/optimizing/instruction_simplifier.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index df6e550b4a..0ac26de674 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -132,6 +132,12 @@ bool InstructionSimplifierVisitor::TryMoveNegOnInputsAfterBinop(HBinaryOperation
// with
// ADD tmp, a, b
// NEG dst, tmp
+ // Note that we cannot optimize `(-a) + (-b)` to `-(a + b)` for floating-point.
+ // When `a` is `-0.0` and `b` is `0.0`, the former expression yields `0.0`,
+ // while the later yields `-0.0`.
+ if (!Primitive::IsIntegralType(binop->GetType())) {
+ return false;
+ }
binop->ReplaceInput(left_neg->GetInput(), 0);
binop->ReplaceInput(right_neg->GetInput(), 1);
left_neg->GetBlock()->RemoveInstruction(left_neg);