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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-662367.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/crankshaft/hydrogen-instructions.cc
diff --git a/src/crankshaft/hydrogen-instructions.cc b/src/crankshaft/hydrogen-instructions.cc
index 465a18ae46e6145d08cb35d5156306cc3ab378d3..8e1d891b47824a0533b93968d1d7ae20ee69df39 100644
--- a/src/crankshaft/hydrogen-instructions.cc
+++ b/src/crankshaft/hydrogen-instructions.cc
@@ -3572,7 +3572,10 @@ HInstruction* HDiv::New(Isolate* isolate, Zone* zone, HValue* context,
HConstant* c_left = HConstant::cast(left);
HConstant* c_right = HConstant::cast(right);
if ((c_left->HasNumberValue() && c_right->HasNumberValue())) {
- if (c_right->DoubleValue() != 0) {
+ if (std::isnan(c_left->DoubleValue()) ||
+ std::isnan(c_right->DoubleValue())) {
+ return H_CONSTANT_DOUBLE(std::numeric_limits<double>::quiet_NaN());
+ } else if (c_right->DoubleValue() != 0) {
double double_res = c_left->DoubleValue() / c_right->DoubleValue();
if (IsInt32Double(double_res)) {
return H_CONSTANT_INT(double_res);
« 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