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

Unified Diff: src/hydrogen-instructions.cc

Issue 172133003: Harmony: optimize Math.clz32. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix Created 6 years, 10 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') | src/ia32/assembler-ia32.h » ('j') | 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 57953857289615f6b3fd3a4f772aa2a81211f492..5b1d3454167f1e8e3fb142bdb286c8021ded2c35 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -1147,6 +1147,7 @@ const char* HUnaryMathOperation::OpName() const {
case kMathExp: return "exp";
case kMathSqrt: return "sqrt";
case kMathPowHalf: return "pow-half";
+ case kMathClz32: return "clz32";
default:
UNREACHABLE();
return NULL;
@@ -1156,6 +1157,7 @@ const char* HUnaryMathOperation::OpName() const {
Range* HUnaryMathOperation::InferRange(Zone* zone) {
Representation r = representation();
+ if (op() == kMathClz32) return new(zone) Range(0, 32);
if (r.IsSmiOrInteger32() && value()->HasRange()) {
if (op() == kMathAbs) {
int upper = value()->range()->upper();
@@ -3925,6 +3927,8 @@ HInstruction* HUnaryMathOperation::New(
case kMathRound:
case kMathFloor:
return H_CONSTANT_DOUBLE(d);
+ case kMathClz32:
+ return H_CONSTANT_INT(32);
default:
UNREACHABLE();
break;
@@ -3950,6 +3954,11 @@ HInstruction* HUnaryMathOperation::New(
return H_CONSTANT_DOUBLE(std::floor(d + 0.5));
case kMathFloor:
return H_CONSTANT_DOUBLE(std::floor(d));
+ case kMathClz32: {
+ uint32_t i = static_cast<uint32_t>(constant->Integer32Value());
+ return H_CONSTANT_INT(
+ (i == 0) ? 32 : CompilerIntrinsics::CountLeadingZeros(i));
+ }
default:
UNREACHABLE();
break;
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/ia32/assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698