Reviewers: ulan,

Description:
Fixed range analysis for HMathFloorOfDiv.

Please review this at https://codereview.chromium.org/195133002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+19, -6 lines):
  M src/hydrogen-instructions.h
  M src/hydrogen-instructions.cc


Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index ba8d03b6f6f8f04839fee8c07dbfcc9a1c33943c..c93bc1144af36376167cbac155e664ec57cda72c 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -1788,7 +1788,7 @@ Range* HMul::InferRange(Zone* zone) {
 }


-Range* HDiv::InferRange(Zone* zone) {
+Range* HBinaryOperation::InferRangeForDiv(Zone* zone) {
   if (representation().IsInteger32()) {
     Range* a = left()->range();
     Range* b = right()->range();
@@ -1797,11 +1797,11 @@ Range* HDiv::InferRange(Zone* zone) {
                                   (a->CanBeMinusZero() ||
(a->CanBeZero() && b->CanBeNegative())));
     if (!a->Includes(kMinInt) || !b->Includes(-1)) {
-      ClearFlag(HValue::kCanOverflow);
+      ClearFlag(kCanOverflow);
     }

     if (!b->CanBeZero()) {
-      ClearFlag(HValue::kCanBeDivByZero);
+      ClearFlag(kCanBeDivByZero);
     }
     return result;
   } else {
@@ -1810,6 +1810,16 @@ Range* HDiv::InferRange(Zone* zone) {
 }


+Range* HDiv::InferRange(Zone* zone) {
+  return InferRangeForDiv(zone);
+}
+
+
+Range* HMathFloorOfDiv::InferRange(Zone* zone) {
+  return InferRangeForDiv(zone);
+}
+
+
 Range* HMod::InferRange(Zone* zone) {
   if (representation().IsInteger32()) {
     Range* a = left()->range();
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index 76d8dfb906c33c236fa6974b629aff0a4bd3fcba..0b4ab0fbc7cd5f195d6244a1a038a36425362505 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -3762,6 +3762,9 @@ class HBinaryOperation : public HTemplateInstruction<3> {

   DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation)

+ protected:
+  Range* InferRangeForDiv(Zone* zone);
+
  private:
   bool IgnoreObservedOutputRepresentation(Representation current_rep);

@@ -4102,12 +4105,12 @@ class HMathFloorOfDiv V8_FINAL : public HBinaryOperation {
     set_representation(Representation::Integer32());
     SetFlag(kUseGVN);
     SetFlag(kCanOverflow);
-    if (!right->IsConstant()) {
-      SetFlag(kCanBeDivByZero);
-    }
+    SetFlag(kCanBeDivByZero);
     SetFlag(kAllowUndefinedAsNaN);
   }

+  virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
+
   virtual bool IsDeletable() const V8_OVERRIDE { return true; }
 };



--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to