Revision: 14322
Author:   [email protected]
Date:     Thu Apr 18 02:24:29 2013
Log:      Unify canonicalization of HAdd/HSub/HMul a bit.

HDiv/HMul are a slightly different story and will be handled in a separate CL.

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

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

=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Wed Apr 17 05:47:15 2013 +++ /branches/bleeding_edge/src/hydrogen-instructions.cc Thu Apr 18 02:24:29 2013
@@ -1422,32 +1422,38 @@
 }


-HValue* HAdd::Canonicalize() {
-  if (!representation().IsInteger32()) return this;
-  if (CheckUsesForFlag(kTruncatingToInt32)) ClearFlag(kCanOverflow);
+HValue* HArithmeticBinaryOperation::Canonicalize() {
+ if (representation().IsInteger32() && CheckUsesForFlag(kTruncatingToInt32)) {
+    ClearFlag(kCanOverflow);
+  }
   return this;
 }


-HValue* HSub::Canonicalize() {
-  if (!representation().IsInteger32()) return this;
-  if (CheckUsesForFlag(kTruncatingToInt32)) ClearFlag(kCanOverflow);
-  return this;
-}
-
-
-// TODO(svenpanne) Use this in other Canonicalize() functions.
static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) {
   return arg1->representation().IsSpecialization() &&
       arg2->IsInteger32Constant() &&
       arg2->GetInteger32Constant() == identity;
 }
+
+
+HValue* HAdd::Canonicalize() {
+  if (IsIdentityOperation(left(), right(), 0)) return left();
+  if (IsIdentityOperation(right(), left(), 0)) return right();
+  return HArithmeticBinaryOperation::Canonicalize();
+}
+
+
+HValue* HSub::Canonicalize() {
+  if (IsIdentityOperation(left(), right(), 0)) return left();
+  return HArithmeticBinaryOperation::Canonicalize();
+}


 HValue* HMul::Canonicalize() {
   if (IsIdentityOperation(left(), right(), 1)) return left();
   if (IsIdentityOperation(right(), left(), 1)) return right();
-  return this;
+  return HArithmeticBinaryOperation::Canonicalize();
 }


=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Wed Apr 17 05:47:15 2013 +++ /branches/bleeding_edge/src/hydrogen-instructions.h Thu Apr 18 02:24:29 2013
@@ -3841,6 +3841,8 @@
         ? Representation::Tagged()
         : representation();
   }
+
+  virtual HValue* Canonicalize();

  private:
   virtual bool IsDeletable() const { 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/groups/opt_out.


Reply via email to