Reviewers: Yang,

Description:
Fixed constant folding for Math.clz32.

LOG=y
BUG=347906

Please review this at https://codereview.chromium.org/184353002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+7, -4 lines):
  M src/hydrogen-instructions.cc
  A + test/mjsunit/regress/regress-347906.js


Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index 29d4e73cba431761f19b5f751e76f2007e51e2e9..a35134952da753ee932fd104ee680e06f5173d2f 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -3955,7 +3955,7 @@ HInstruction* HUnaryMathOperation::New(
       case kMathFloor:
         return H_CONSTANT_DOUBLE(std::floor(d));
       case kMathClz32: {
-        uint32_t i = static_cast<uint32_t>(constant->Integer32Value());
+        uint32_t i = DoubleToUint32(d);
         return H_CONSTANT_INT(
             (i == 0) ? 32 : CompilerIntrinsics::CountLeadingZeros(i));
       }
Index: test/mjsunit/regress/regress-347906.js
diff --git a/test/mjsunit/regress/regress-347542.js b/test/mjsunit/regress/regress-347906.js
similarity index 68%
copy from test/mjsunit/regress/regress-347542.js
copy to test/mjsunit/regress/regress-347906.js
index 901d798fb7fbea45f0d9f3d8ba6c7a9846bf6dd6..c751618928c93015679087ee1b500637657aa341 100644
--- a/test/mjsunit/regress/regress-347542.js
+++ b/test/mjsunit/regress/regress-347906.js
@@ -2,10 +2,13 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.

-// Flags: --allow-natives-syntax
+// Flags: --allow-natives-syntax --harmony

-function foo() {}
+function foo() {
+  return Math.clz32(12.34);
+}
+
+foo();
 foo();
 %OptimizeFunctionOnNextCall(foo);
 foo();
-%NeverOptimizeFunction(foo);


--
--
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