diff options
| author | 2015-08-21 13:26:34 +0600 | |
|---|---|---|
| committer | 2015-08-27 10:05:38 +0600 | |
| commit | aae9e66a727756bc965121a60ffcef89ed370e6c (patch) | |
| tree | 871d86b73428f998e1099135118c515e3f623fb4 /compiler/optimizing/instruction_simplifier.cc | |
| parent | 772cc4a2d4f978888d1b1e5a78c1c16a108260ed (diff) | |
ART: Fix the simplifier for NEGATE add/sub
Instruction simplifier for negate add/sub should not proceed
with floats because that might cause the incorrect behavior
with signed zero.
Change-Id: I4970694a2b265a3577cde34fee9cd3a437358c0f
Diffstat (limited to 'compiler/optimizing/instruction_simplifier.cc')
| -rw-r--r-- | compiler/optimizing/instruction_simplifier.cc | 6 |
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); |