Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Unified Diff: src/hydrogen-instructions.cc

Issue 14296013: Unify canonicalization of HAdd/HSub/HMul a bit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed feedback. Rebased. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index 0aabfbc43229198f181ec9f76d4aaf4724228f4f..71158cee12f1a5fcfb2bdd40a7e8096cbc9522f3 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -1422,21 +1422,14 @@ HValue* HBitNot::Canonicalize() {
}
-HValue* HAdd::Canonicalize() {
- if (!representation().IsInteger32()) return this;
- if (CheckUsesForFlag(kTruncatingToInt32)) ClearFlag(kCanOverflow);
- return this;
-}
-
-
-HValue* HSub::Canonicalize() {
- if (!representation().IsInteger32()) return this;
- if (CheckUsesForFlag(kTruncatingToInt32)) ClearFlag(kCanOverflow);
+HValue* HArithmeticBinaryOperation::Canonicalize() {
+ if (representation().IsInteger32() && 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() &&
@@ -1444,10 +1437,23 @@ static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t 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();
}
« no previous file with comments | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698