diff options
author | Serguei Katkov <serguei.i.katkov@intel.com> | 2015-04-20 12:29:32 +0600 |
---|---|---|
committer | Serguei Katkov <serguei.i.katkov@intel.com> | 2015-04-20 23:47:16 +0600 |
commit | 339dfc209ad93482269eea1386e79973abc313cf (patch) | |
tree | cd0173a02590ead4fe7064a9b8f6ebf12a341ec5 /compiler/optimizing | |
parent | f5091eee4abe73c64959e53bda684bd689569643 (diff) | |
download | art-339dfc209ad93482269eea1386e79973abc313cf.zip art-339dfc209ad93482269eea1386e79973abc313cf.tar.gz art-339dfc209ad93482269eea1386e79973abc313cf.tar.bz2 |
Incorrect transformation of (sub,neg) to (sub) for fp
A pair (sub,neg) should not be transformed to (sub) for
floating point operations, otherwise we can lose the sign of
zero for instructions like this:
- (A - B) != B - A if B == A
Change-Id: I4d612612d4dc0a067fac5721ad206f74168bcd36
Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com>
Diffstat (limited to 'compiler/optimizing')
-rw-r--r-- | compiler/optimizing/instruction_simplifier.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc index afbc490..180bdc9 100644 --- a/compiler/optimizing/instruction_simplifier.cc +++ b/compiler/optimizing/instruction_simplifier.cc @@ -424,7 +424,8 @@ void InstructionSimplifierVisitor::VisitNeg(HNeg* instruction) { return; } - if (input->IsSub() && input->HasOnlyOneNonEnvironmentUse()) { + if (input->IsSub() && input->HasOnlyOneNonEnvironmentUse() && + !Primitive::IsFloatingPointType(input->GetType())) { // Replace code looking like // SUB tmp, a, b // NEG dst, tmp @@ -435,6 +436,7 @@ void InstructionSimplifierVisitor::VisitNeg(HNeg* instruction) { // worse code. In particular, we do not want the live ranges of `a` and `b` // to be extended if we are not sure the initial 'SUB' instruction can be // removed. + // We do not perform optimization for fp because we could lose the sign of zero. HSub* sub = input->AsSub(); HSub* new_sub = new (GetGraph()->GetArena()) HSub(instruction->GetType(), sub->GetRight(), sub->GetLeft()); |