remove some instruction bloat in S_find_uninit_var
authorDaniel Dragan <bulk88@hotmail.com>
Sat, 22 Dec 2012 14:34:40 +0000 (09:34 -0500)
committerTony Cook <tony@develop-help.com>
Fri, 19 Jul 2013 05:36:23 +0000 (15:36 +1000)
VC 2003 -O1 put down SvIV(cSVOPx_sv(kid)) twice in asm. Not sure why.

Explicitly store the values to make it more obvious to the compiler to
evaluate the SvIV only once, then do the branch, not do the negate branch,
then in a negate branch do a SvIV. Result is less machine code read by the
CPU. The .text section dropped 0xC01FF to 0xC018F after this change.

sv.c

diff --git a/sv.c b/sv.c
index 3977204..3ac0a2b 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -14413,8 +14413,10 @@ S_find_uninit_var(pTHX_ const OP *const obase, const SV *const uninit_sv,
                        break;
                }
                else {
+                   SV * const  opsv = cSVOPx_sv(kid);
+                   const IV  opsviv = SvIV(opsv);
                    SV * const * const svp = av_fetch(MUTABLE_AV(sv),
-                       negate ? - SvIV(cSVOPx_sv(kid)) : SvIV(cSVOPx_sv(kid)),
+                       negate ? - opsviv : opsviv,
                        FALSE);
                    if (!svp || *svp != uninit_sv)
                        break;