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

Unified Diff: runtime/vm/assembler_ia32_test.cc

Issue 92433002: Merge sin(a), cos(a) into one instruction. TODO: Implement for ARM and MIPS. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
Index: runtime/vm/assembler_ia32_test.cc
===================================================================
--- runtime/vm/assembler_ia32_test.cc (revision 30802)
+++ runtime/vm/assembler_ia32_test.cc (working copy)
@@ -2016,6 +2016,31 @@
}
+ASSEMBLER_TEST_GENERATE(SinCos, assembler) {
+ __ fldl(Address(ESP, kWordSize));
+ __ fsincos();
+ __ subl(ESP, Immediate(2 * kWordSize));
+ __ fstpl(Address(ESP, 0)); // cos result.
+ __ movsd(XMM0, Address(ESP, 0));
+ __ fstpl(Address(ESP, 0)); // sin result.
+ __ movsd(XMM1, Address(ESP, 0));
+ __ subsd(XMM1, XMM0); // sin - cos.
+ __ movsd(Address(ESP, 0), XMM1);
+ __ fldl(Address(ESP, 0));
+ __ addl(ESP, Immediate(2 * kWordSize));
+ __ ret();
+}
+
+
+ASSEMBLER_TEST_RUN(SinCos, test) {
+ typedef double (*SinCosCode)(double d);
+ const double arg = 1.2345;
+ const double expected = sin(arg) - cos(arg);
+ double res = reinterpret_cast<SinCosCode>(test->entry())(arg);
+ EXPECT_FLOAT_EQ(expected, res, 0.000001);
+}
+
+
ASSEMBLER_TEST_GENERATE(Tangent, assembler) {
__ fldl(Address(ESP, kWordSize));
__ fptan();

Powered by Google App Engine
This is Rietveld 408576698