Revision: 14644
Author:   [email protected]
Date:     Mon May 13 06:48:15 2013
Log: Consistently assume that arithmetic operations can overflow unless one can prove the opposite.

Previously, HDiv never had its CanOverflow flag cleared and HMod had
inverted logic (compared to HAdd, HSub and HMul). Minor cleanups on the way.

[email protected]

Review URL: https://codereview.chromium.org/14617015
http://code.google.com/p/v8/source/detail?r=14644

Modified:
 /branches/bleeding_edge/src/hydrogen-instructions.cc
 /branches/bleeding_edge/src/hydrogen-instructions.h

=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Mon May 13 04:51:49 2013 +++ /branches/bleeding_edge/src/hydrogen-instructions.cc Mon May 13 06:48:15 2013
@@ -1443,6 +1443,16 @@
   if (IsIdentityOperation(right(), left(), 1)) return right();
   return this;
 }
+
+
+HValue* HMod::Canonicalize() {
+  return this;
+}
+
+
+HValue* HDiv::Canonicalize() {
+  return this;
+}


 HValue* HChange::Canonicalize() {
@@ -1773,20 +1783,22 @@

 Range* HDiv::InferRange(Zone* zone) {
   if (representation().IsInteger32()) {
+    Range* a = left()->range();
+    Range* b = right()->range();
     Range* result = new(zone) Range();
-    if (left()->range()->CanBeMinusZero()) {
+    if (a->CanBeMinusZero()) {
       result->set_can_be_minus_zero(true);
     }

- if (left()->range()->CanBeZero() && right()->range()->CanBeNegative()) {
+    if (a->CanBeZero() && b->CanBeNegative()) {
       result->set_can_be_minus_zero(true);
     }

- if (right()->range()->Includes(-1) && left()->range()->Includes(kMinInt)) {
-      SetFlag(HValue::kCanOverflow);
+    if (!a->Includes(kMinInt) || !b->Includes(-1)) {
+      ClearFlag(HValue::kCanOverflow);
     }

-    if (!right()->range()->CanBeZero()) {
+    if (!b->CanBeZero()) {
       ClearFlag(HValue::kCanBeDivByZero);
     }
     return result;
@@ -1799,16 +1811,17 @@
 Range* HMod::InferRange(Zone* zone) {
   if (representation().IsInteger32()) {
     Range* a = left()->range();
+    Range* b = right()->range();
     Range* result = new(zone) Range();
     if (a->CanBeMinusZero() || a->CanBeNegative()) {
       result->set_can_be_minus_zero(true);
     }

- if (right()->range()->Includes(-1) && left()->range()->Includes(kMinInt)) {
-      SetFlag(HValue::kCanOverflow);
+    if (!a->Includes(kMinInt) || !b->Includes(-1)) {
+      ClearFlag(HValue::kCanOverflow);
     }

-    if (!right()->range()->CanBeZero()) {
+    if (!b->CanBeZero()) {
       ClearFlag(HValue::kCanBeDivByZero);
     }
     return result;
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Mon May 13 04:58:10 2013 +++ /branches/bleeding_edge/src/hydrogen-instructions.h Mon May 13 06:48:15 2013
@@ -4414,6 +4414,8 @@

   virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);

+  virtual HValue* Canonicalize();
+
   DECLARE_CONCRETE_INSTRUCTION(Mod)

  protected:
@@ -4425,6 +4427,7 @@
   HMod(HValue* context, HValue* left, HValue* right)
       : HArithmeticBinaryOperation(context, left, right) {
     SetFlag(kCanBeDivByZero);
+    SetFlag(kCanOverflow);
   }
 };

@@ -4448,6 +4451,8 @@

   virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);

+  virtual HValue* Canonicalize();
+
   DECLARE_CONCRETE_INSTRUCTION(Div)

  protected:

--
--
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/groups/opt_out.


Reply via email to