Status: Accepted
Owner: [email protected]
Labels: Type-Bug Priority-Medium

New issue 3477 by [email protected]: Math.floor(-0) returns the wrong result when V8 is compiled with MSVC 10.0 with /arch:SSE2
http://code.google.com/p/v8/issues/detail?id=3477

Math.floor(-0) returns 0 instead of -0.

The reason is that the runtime function is implemented using std::floor, which is compiled to the following sequence by MSVC 10.0, if SSE2 is enabled and the build target is release mode ia32.

00BF8E8B  movsd       xmm2,mmword ptr [eax+3]    <-- load from heap number
00BF8E90  int         3                          <-- debug break
00BF8E91  test        byte ptr [$S1 (0ED4A58h)],1
00BF8E98  movsd       xmm5,mmword ptr [__real@8000000000000000 (0D801A8h)]
00BF8EA0  movsd       xmm1,mmword ptr [__real@4330000000000000 (0D801C0h)]
00BF8EA8  movsd       xmm4,mmword ptr [__real@3ff0000000000000 (0D866A0h)]
00BF8EB0  movapd      xmm0,xmm5
00BF8EB4  andpd       xmm0,xmm2
00BF8EB8  movapd      xmm3,xmm0
00BF8EBC  movapd      xmm0,xmm2
00BF8EC0  xorpd       xmm0,xmm3
00BF8EC4  cmpltsd     xmm0,xmm1
00BF8EC9  andpd       xmm1,xmm0
00BF8ECD  orpd        xmm1,xmm3
00BF8ED1  movapd      xmm0,xmm2
00BF8ED5  addsd       xmm0,xmm1  <--
00BF8ED9  subsd       xmm0,xmm1
00BF8EDD  movapd      xmm1,xmm0
00BF8EE1  subsd       xmm1,xmm2
00BF8EE5  cmpnlesd    xmm1,xmm3
00BF8EEA  andpd       xmm1,xmm4
00BF8EEE  subsd       xmm0,xmm1

At the addsd instruction, -0 is added to 0, which removes the sign. The final result is 0, which is wrong.

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
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/d/optout.

Reply via email to