This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Skip padrange optimisation for one padop
authorFather Chrysostomos <sprout@cpan.org>
Fri, 17 Oct 2014 20:07:31 +0000 (13:07 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 17 Oct 2014 20:16:46 +0000 (13:16 -0700)
cachegrind shows that padrange is marginally slower than pushmark+padsv
(<20141017140518.GF5204@iabyn.com>).

ext/B/t/optree_sort.t
op.c

index a78b31e..660d9b2 100644 (file)
@@ -196,9 +196,10 @@ checkOptree ( name => 'sub {my @a; @a = sort @a}',
 5  <0> pushmark s
 6  <0> padav[@a:-437,-436] l
 7  <@> sort lK
-8  <0> padrange[@a:-437,-436] l/1
-9  <2> aassign[t2] KS/COMMON
-a  <1> leavesub[1 ref] K/REFC,1
+8  <0> pushmark s
+9  <0> padav[@a:-437,-436] lRM*
+a  <2> aassign[t2] KS/COMMON
+b  <1> leavesub[1 ref] K/REFC,1
 EOT_EOT
 # 1  <;> nextstate(main 427 optree_sort.t:172) v:>,<,%
 # 2  <0> padav[@a:427,428] vM/LVINTRO
@@ -207,9 +208,10 @@ EOT_EOT
 # 5  <0> pushmark s
 # 6  <0> padav[@a:427,428] l
 # 7  <@> sort lK
-# 8  <0> padrange[@a:427,428] l/1
-# 9  <2> aassign[t2] KS/COMMON
-# a  <1> leavesub[1 ref] K/REFC,1
+# 8  <0> pushmark s
+# 9  <0> padav[@a:-437,-436] lRM*
+# a  <2> aassign[t2] KS/COMMON
+# b  <1> leavesub[1 ref] K/REFC,1
 EONT_EONT
 
 checkOptree ( name     => 'my @a; @a = sort @a',
@@ -222,18 +224,20 @@ checkOptree ( name        => 'my @a; @a = sort @a',
 3  <0> padav[@a:1,2] vM/LVINTRO
 4  <;> nextstate(main 2 -e:1) v:>,<,%,{
 5  <0> pushmark s
-6  <0> padrange[@a:1,2] l/1
-7  <@> sort lK/INPLACE
-8  <@> leave[1 ref] vKP/REFC
+6  <0> pushmark s
+7  <0> padav[@a:1,2] lRM*
+8  <@> sort lK/INPLACE
+9  <@> leave[1 ref] vKP/REFC
 EOT_EOT
 # 1  <0> enter 
 # 2  <;> nextstate(main 1 -e:1) v:>,<,%,{
 # 3  <0> padav[@a:1,2] vM/LVINTRO
 # 4  <;> nextstate(main 2 -e:1) v:>,<,%,{
 # 5  <0> pushmark s
-# 6  <0> padrange[@a:1,2] l/1
-# 7  <@> sort lK/INPLACE
-# 8  <@> leave[1 ref] vKP/REFC
+# 6  <0> pushmark s
+# 7  <0> padav[@a:1,2] lRM*
+# 8  <@> sort lK/INPLACE
+# 9  <@> leave[1 ref] vKP/REFC
 EONT_EONT
 
 checkOptree ( name     => 'sub {my @a; @a = sort @a; push @a, 1}',
@@ -246,25 +250,29 @@ checkOptree ( name        => 'sub {my @a; @a = sort @a; push @a, 1}',
 2  <0> padav[@a:-437,-436] vM/LVINTRO
 3  <;> nextstate(main -436 optree.t:325) v:>,<,%
 4  <0> pushmark s
-5  <0> padrange[@a:-437,-436] l/1
-6  <@> sort lK/INPLACE
-7  <;> nextstate(main -436 optree.t:325) v:>,<,%,{
-8  <0> padrange[@a:-437,-436] l/1
-9  <$> const[IV 1] s
-a  <@> push[t3] sK/2
-b  <1> leavesub[1 ref] K/REFC,1
+5  <0> pushmark s
+6  <0> padav[@a:-437,-436] lRM*
+7  <@> sort lK/INPLACE
+8  <;> nextstate(main -436 optree.t:325) v:>,<,%,{
+9  <0> pushmark s
+a  <0> padav[@a:-437,-436] lRM
+b  <$> const[IV 1] s
+c  <@> push[t3] sK/2
+d  <1> leavesub[1 ref] K/REFC,1
 EOT_EOT
 # 1  <;> nextstate(main 429 optree_sort.t:219) v:>,<,%
 # 2  <0> padav[@a:429,430] vM/LVINTRO
 # 3  <;> nextstate(main 430 optree_sort.t:220) v:>,<,%
 # 4  <0> pushmark s
-# 5  <0> padrange[@a:429,430] l/1
-# 6  <@> sort lK/INPLACE
-# 7  <;> nextstate(main 430 optree_sort.t:220) v:>,<,%,{
-# 8  <0> padrange[@a:429,430] l/1
-# 9  <$> const(IV 1) s
-# a  <@> push[t3] sK/2
-# b  <1> leavesub[1 ref] K/REFC,1
+# 5  <0> pushmark s
+# 6  <0> padav[@a:429,430] lRM*
+# 7  <@> sort lK/INPLACE
+# 8  <;> nextstate(main 430 optree_sort.t:220) v:>,<,%,{
+# 9  <0> pushmark s
+# a  <0> padav[@a:429,430] lRM
+# b  <$> const(IV 1) s
+# c  <@> push[t3] sK/2
+# d  <1> leavesub[1 ref] K/REFC,1
 EONT_EONT
 
 checkOptree ( name     => 'sub {my @a; @a = sort @a; 1}',
@@ -277,19 +285,21 @@ checkOptree ( name        => 'sub {my @a; @a = sort @a; 1}',
 2  <0> padav[@a:-437,-436] vM/LVINTRO
 3  <;> nextstate(main -436 optree.t:325) v:>,<,%
 4  <0> pushmark s
-5  <0> padrange[@a:-437,-436] l/1
-6  <@> sort lK/INPLACE
-7  <;> nextstate(main -436 optree.t:346) v:>,<,%,{
-8  <$> const[IV 1] s
-9  <1> leavesub[1 ref] K/REFC,1
+5  <0> pushmark s
+6  <0> padav[@a:-437,-436] lRM*
+7  <@> sort lK/INPLACE
+8  <;> nextstate(main -436 optree.t:346) v:>,<,%,{
+9  <$> const[IV 1] s
+a  <1> leavesub[1 ref] K/REFC,1
 EOT_EOT
 # 1  <;> nextstate(main 431 optree_sort.t:250) v:>,<,%
 # 2  <0> padav[@a:431,432] vM/LVINTRO
 # 3  <;> nextstate(main 432 optree_sort.t:251) v:>,<,%
 # 4  <0> pushmark s
-# 5  <0> padrange[@a:431,432] l/1
-# 6  <@> sort lK/INPLACE
-# 7  <;> nextstate(main 432 optree_sort.t:251) v:>,<,%,{
-# 8  <$> const(IV 1) s
-# 9  <1> leavesub[1 ref] K/REFC,1
+# 5  <0> pushmark s
+# 6  <0> padav[@a:431,432] lRM*
+# 7  <@> sort lK/INPLACE
+# 8  <;> nextstate(main 432 optree_sort.t:251) v:>,<,%,{
+# 9  <$> const(IV 1) s
+# a  <1> leavesub[1 ref] K/REFC,1
 EONT_EONT
diff --git a/op.c b/op.c
index f14c5af..44d52f9 100644 (file)
--- a/op.c
+++ b/op.c
@@ -12073,7 +12073,7 @@ Perl_rpeep(pTHX_ OP *o)
                 followop = p->op_next;
             }
 
-            if (count < 1)
+            if (count < 1 || (count == 1 && !defav))
                 break;
 
             /* pp_padrange in specifically compile-time void context