Comment #2 on issue 2205 by [email protected]: MathFloorOfDiv optimization is very fragile
http://code.google.com/p/v8/issues/detail?id=2205

One more data point. For the function like this:

function foo(x, y) {
  return Math.floor(~~x / ~~y);
}

We produce:

                  ;;; <@18,#26> tagged-to-i
0x26e2c92c    44  a801           test al,0x1
0x26e2c92e    46  0f8598000000   jnz 204  (0x26e2c9cc)
0x26e2c934    52  d1f8           sar eax,1
                  ;;; <@19,#26> gap
0x26e2c936    54  8b5d08         mov ebx,[ebp+0x8]
                  ;;; <@20,#27> tagged-to-i
0x26e2c939    57  f6c301         test_b bl,0x1
0x26e2c93c    60  0f85cf000000   jnz 273  (0x26e2ca11)
0x26e2c942    66  d1fb           sar ebx,1
                  ;;; <@22,#18> div-i
0x26e2c944    68  85db           test ebx,ebx
0x26e2c946    70  0f8474010000   jz 448  (0x26e2cac0)
0x26e2c94c    76  85c0           test eax,eax
0x26e2c94e    78  7508           jnz 88  (0x26e2c958)
0x26e2c950    80  85db           test ebx,ebx
0x26e2c952    82  0f8868010000   js 448  (0x26e2cac0)
0x26e2c958    88  3d00000080     cmp eax, 0x80000000
0x26e2c95d    93  7509           jnz 104  (0x26e2c968)
0x26e2c95f    95  83fbff         cmp ebx,0xff
0x26e2c962    98  0f8458010000   jz 448  (0x26e2cac0)
0x26e2c968   104  99             cdq
0x26e2c969   105  f7fb           idiv ebx
0x26e2c96b   107  85d2           test edx,edx
0x26e2c96d   109  0f854d010000   jnz 448  (0x26e2cac0)
                  ;;; <@24,#20> check-non-smi
0x26e2c973   115  f7c101000000   test ecx,0x1
0x26e2c979   121  0f8446010000   jz 453  (0x26e2cac5)
                  ;;; <@26,#21> check-maps
0x26e2c97f 127 8179ff39dcf03d cmp [ecx+0xff],0x3df0dc39 ;; object: 0x3df0dc39 <Map(elements=3)>
0x26e2c986   134  0f853e010000   jnz 458  (0x26e2caca)
                  ;;; <@28,#28> int32-to-double
0x26e2c98c   140  f20f2ac8       cvtsi2sd xmm1,eax
                  ;;; <@30,#22> math-floor
0x26e2c990   144  0f57c0         xorps xmm0,xmm0
0x26e2c993   147  660f2ec8       ucomisd xmm1,xmm0
0x26e2c997   151  750d           jnz 166  (0x26e2c9a6)
0x26e2c999   153  660f50d1       movmskpd edx,xmm1
0x26e2c99d   157  f6c201         test_b dl,0x1
0x26e2c9a0   160  0f8529010000   jnz 463  (0x26e2cacf)
0x26e2c9a6   166  660f3a0bc109   roundsd xmm0,xmm1,9
0x26e2c9ac   172  f20f2cd0       cvttsd2si edx,xmm0
0x26e2c9b0   176  81fa00000080   cmp edx,0x80000000
0x26e2c9b6   182  0f8413010000   jz 463  (0x26e2cacf)
                  ;;; <@32,#29> number-tag-i
0x26e2c9bc   188  03d2           add edx,edx
0x26e2c9be   190  0f8095000000   jo 345  (0x26e2ca59)

That's a lot of redundant code.

--
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/groups/opt_out.


Reply via email to