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

Unified Diff: src/hydrogen-instructions.cc

Issue 14617015: Consistently assume that arithmetic operations can overflow unless one can prove the opposite. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 7 years, 7 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 bf1977824ada2dfeecaf98dd0a6caa52301236c8..78e1229de643102fc206da50dc1e4f944ae46b14 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -1445,6 +1445,16 @@ HValue* HMul::Canonicalize() {
}
+HValue* HMod::Canonicalize() {
+ return this;
+}
+
+
+HValue* HDiv::Canonicalize() {
+ return this;
+}
+
+
HValue* HChange::Canonicalize() {
return (from().Equals(to())) ? value() : this;
}
@@ -1773,20 +1783,22 @@ Range* HMul::InferRange(Zone* zone) {
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* HDiv::InferRange(Zone* zone) {
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;
« 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