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

Side by Side Diff: src/crankshaft/hydrogen-instructions.cc

Issue 2486923004: [crankshaft] Fix constant folding of HDiv instruction. (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-662367.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/crankshaft/hydrogen-instructions.h" 5 #include "src/crankshaft/hydrogen-instructions.h"
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/ieee754.h" 8 #include "src/base/ieee754.h"
9 #include "src/base/safe_math.h" 9 #include "src/base/safe_math.h"
10 #include "src/crankshaft/hydrogen-infer-representation.h" 10 #include "src/crankshaft/hydrogen-infer-representation.h"
(...skipping 3554 matching lines...) Expand 10 before | Expand all | Expand 10 after
3565 return new (zone) HMod(context, left, right); 3565 return new (zone) HMod(context, left, right);
3566 } 3566 }
3567 3567
3568 HInstruction* HDiv::New(Isolate* isolate, Zone* zone, HValue* context, 3568 HInstruction* HDiv::New(Isolate* isolate, Zone* zone, HValue* context,
3569 HValue* left, HValue* right) { 3569 HValue* left, HValue* right) {
3570 // If left and right are constant values, try to return a constant value. 3570 // If left and right are constant values, try to return a constant value.
3571 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { 3571 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) {
3572 HConstant* c_left = HConstant::cast(left); 3572 HConstant* c_left = HConstant::cast(left);
3573 HConstant* c_right = HConstant::cast(right); 3573 HConstant* c_right = HConstant::cast(right);
3574 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { 3574 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) {
3575 if (c_right->DoubleValue() != 0) { 3575 if (std::isnan(c_left->DoubleValue()) ||
3576 std::isnan(c_right->DoubleValue())) {
3577 return H_CONSTANT_DOUBLE(std::numeric_limits<double>::quiet_NaN());
3578 } else if (c_right->DoubleValue() != 0) {
3576 double double_res = c_left->DoubleValue() / c_right->DoubleValue(); 3579 double double_res = c_left->DoubleValue() / c_right->DoubleValue();
3577 if (IsInt32Double(double_res)) { 3580 if (IsInt32Double(double_res)) {
3578 return H_CONSTANT_INT(double_res); 3581 return H_CONSTANT_INT(double_res);
3579 } 3582 }
3580 return H_CONSTANT_DOUBLE(double_res); 3583 return H_CONSTANT_DOUBLE(double_res);
3581 } else if (c_left->DoubleValue() != 0) { 3584 } else if (c_left->DoubleValue() != 0) {
3582 int sign = Double(c_left->DoubleValue()).Sign() * 3585 int sign = Double(c_left->DoubleValue()).Sign() *
3583 Double(c_right->DoubleValue()).Sign(); // Right could be -0. 3586 Double(c_right->DoubleValue()).Sign(); // Right could be -0.
3584 return H_CONSTANT_DOUBLE(sign * V8_INFINITY); 3587 return H_CONSTANT_DOUBLE(sign * V8_INFINITY);
3585 } else { 3588 } else {
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
4032 case HObjectAccess::kExternalMemory: 4035 case HObjectAccess::kExternalMemory:
4033 os << "[external-memory]"; 4036 os << "[external-memory]";
4034 break; 4037 break;
4035 } 4038 }
4036 4039
4037 return os << "@" << access.offset(); 4040 return os << "@" << access.offset();
4038 } 4041 }
4039 4042
4040 } // namespace internal 4043 } // namespace internal
4041 } // namespace v8 4044 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-662367.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698