From f9f196c55f3b25c3b09350cd8ed5d7ead31f1757 Mon Sep 17 00:00:00 2001 From: Anton Shamin Date: Tue, 8 Sep 2015 17:33:16 +0600 Subject: Change condition to opposite if lhs is constant Swap operands if lhs is constant. Handeled unsigned comparison in insruction simplifier. Fixed NaN comparison: no matter what bias is set result of Equal and NotEqual operations should not depend on it. Added checker tests. Change-Id: I5a9ac25fb10f2705127a52534867cee43368ed1b Signed-off-by: Anton Shamin Signed-off-by: Serguei Katkov --- compiler/optimizing/nodes.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'compiler/optimizing/nodes.h') diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index c06d164523..cfb71791f4 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -2706,6 +2706,8 @@ class HCondition : public HBinaryOperation { bool IsGtBias() const { return bias_ == ComparisonBias::kGtBias; } + bool IsLtBias() const { return bias_ == ComparisonBias::kLtBias; } + void SetBias(ComparisonBias bias) { bias_ = bias; } bool InstructionDataEquals(HInstruction* other) const OVERRIDE { @@ -2715,13 +2717,23 @@ class HCondition : public HBinaryOperation { bool IsFPConditionTrueIfNaN() const { DCHECK(Primitive::IsFloatingPointType(InputAt(0)->GetType())); IfCondition if_cond = GetCondition(); - return IsGtBias() ? ((if_cond == kCondGT) || (if_cond == kCondGE)) : (if_cond == kCondNE); + if (if_cond == kCondNE) { + return true; + } else if (if_cond == kCondEQ) { + return false; + } + return ((if_cond == kCondGT) || (if_cond == kCondGE)) && IsGtBias(); } bool IsFPConditionFalseIfNaN() const { DCHECK(Primitive::IsFloatingPointType(InputAt(0)->GetType())); IfCondition if_cond = GetCondition(); - return IsGtBias() ? ((if_cond == kCondLT) || (if_cond == kCondLE)) : (if_cond == kCondEQ); + if (if_cond == kCondEQ) { + return true; + } else if (if_cond == kCondNE) { + return false; + } + return ((if_cond == kCondLT) || (if_cond == kCondLE)) && IsGtBias(); } private: -- cgit v1.2.3-59-g8ed1b