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

Unified Diff: src/ia32/code-stubs-ia32.cc

Issue 8820007: Skip check for +/-0.5 in optimized Math.pow (ia32). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ia32/code-stubs-ia32.cc
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc
index 0afc9cc6e02ed65a0dc1803723c60a14429ff211..c9d8cfd4d5941883c545982ad5464417d198ba8e 100644
--- a/src/ia32/code-stubs-ia32.cc
+++ b/src/ia32/code-stubs-ia32.cc
@@ -3025,38 +3025,43 @@ void MathPowStub::Generate(MacroAssembler* masm) {
__ ucomisd(xmm2, xmm4);
__ j(equal, &int_exponent);
- // Detect square root case.
- // Test for -0.5.
- // Load xmm4 with -0.5.
- __ mov(ecx, Immediate(0xBF000000u));
- __ movd(xmm4, ecx);
- __ cvtss2sd(xmm4, xmm4);
- // xmm3 now has -0.5.
- __ ucomisd(xmm4, xmm2);
- __ j(not_equal, &not_minus_half, Label::kNear);
-
- // Calculates reciprocal of square root.eax
- // sqrtsd returns -0 when input is -0. ECMA spec requires +0.
- __ xorps(xmm2, xmm2);
- __ addsd(xmm2, xmm1);
- __ sqrtsd(xmm2, xmm2);
- __ divsd(xmm3, xmm2);
- __ jmp(&done);
-
- // Test for 0.5.
- __ bind(&not_minus_half);
- // Load xmm2 with 0.5.
- // Since xmm3 is 1 and xmm4 is -0.5 this is simply xmm4 + xmm3.
- __ addsd(xmm4, xmm3);
- // xmm2 now has 0.5.
- __ ucomisd(xmm4, xmm2);
- __ j(not_equal, &fast_power, Label::kNear);
- // Calculates square root.
- // sqrtsd returns -0 when input is -0. ECMA spec requires +0.
- __ xorps(xmm4, xmm4);
- __ addsd(xmm4, xmm1);
- __ sqrtsd(xmm3, xmm4);
- __ jmp(&done);
+ if (exponent_type_ == ON_STACK) {
+ // Detect square root case. Crankshaft detects constant +/-0.5 at
+ // compile time and uses DoMathPowHalf instead. We then skip this check
+ // for non-constant cases of +/-0.5 as these hardly occur.
+
+ // Test for -0.5.
+ // Load xmm4 with -0.5.
+ __ mov(ecx, Immediate(0xBF000000u));
+ __ movd(xmm4, ecx);
+ __ cvtss2sd(xmm4, xmm4);
+ // xmm3 now has -0.5.
+ __ ucomisd(xmm4, xmm2);
+ __ j(not_equal, &not_minus_half, Label::kNear);
+
+ // Calculates reciprocal of square root.eax
+ // sqrtsd returns -0 when input is -0. ECMA spec requires +0.
+ __ xorps(xmm2, xmm2);
+ __ addsd(xmm2, xmm1);
+ __ sqrtsd(xmm2, xmm2);
+ __ divsd(xmm3, xmm2);
+ __ jmp(&done);
+
+ // Test for 0.5.
+ __ bind(&not_minus_half);
+ // Load xmm2 with 0.5.
+ // Since xmm3 is 1 and xmm4 is -0.5 this is simply xmm4 + xmm3.
+ __ addsd(xmm4, xmm3);
+ // xmm2 now has 0.5.
+ __ ucomisd(xmm4, xmm2);
+ __ j(not_equal, &fast_power, Label::kNear);
+ // Calculates square root.
+ // sqrtsd returns -0 when input is -0. ECMA spec requires +0.
+ __ xorps(xmm4, xmm4);
+ __ addsd(xmm4, xmm1);
+ __ sqrtsd(xmm3, xmm4);
+ __ jmp(&done);
+ }
// Using FPU instructions to calculate power.
Label fast_power_failed;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698