Front page | perl.perl5.porters |
Postings from September 2010
Re: [perl #77536] [PATCH] Support B::Generate and B::C
Thread Previous
From:
Jim Cromie
Date:
September 1, 2010 14:42
Subject:
Re: [perl #77536] [PATCH] Support B::Generate and B::C
Message ID:
AANLkTi=jLwHt19WJxph3WhqPY+Vt1gDtEKRiKqtGpAzs@mail.gmail.com
On Tue, Aug 31, 2010 at 3:50 PM, Reini Urban via RT <
perlbug-followup@perl.org> wrote:
> Jim Cromie (via RT) schrieb:
> > # New Ticket Created by Jim Cromie
> > # Please include the string: [perl #77536]
> >> e: implements 'use integer';
> > can you suggest perl statements that trigger these particular cases ?
>
> I already posted a similar example with and without.
> Just look for i_add vs add, and i_modulo vs modulo.
>
yes - I see that now,
I'll add several tests ( -Minteger etc) to my B-Concise based test patch,
along these lines youve outlined.
Ive tested fold-constants wrt Nicks a-e comments,
core tests fail badly in basically every removal or goto nope case.
Its unclear to me why it should be your burden to say so,
nor is it clear that saying it will be sufficient.
And my "system" tests work fine as a test of internal behavior.
Itd be nice if he noted that, rather than harp on their insufficiency
for API tests, which hes against anyway.
So, to doublecheck, you still want embed with XM rather than A, correct ?
> From worse to better, so you see how bad the optimiser really is.
> I wouldn't really test this, because it should be kept
> implementation dependent how "good" our optimizer is.
>
Im not sure I agree - a few failures wouldnt slow down somebody
determined enough to even start improving the peep-optimizer.
esp if theres a "not much optimization happening here" after the OK.
I wonder whats needed to catch and optimize
{ my $foo = 1; print $foo+2 }
similar to your 1st example, but with known scope
SSA for perl sounds like too much work.
>
> Do almost nothing, slow: ($n is not detected as constant)
>
> $ perl -MO=Terse -e '$n=1127;$result=($n%1000)+167772160;'
> LISTOP (0x16b22a0) leave [1]
> OP (0x16b2458) enter
> COP (0x16b2258) nextstate
> BINOP (0x16b2230) sassign
> SVOP (0x16b2210) const [6] IV (0x15a2138) 1127
> UNOP (0x16b21f0) null [15]
> PADOP (0x16b21d0) gvsv GV (0x15a2150) *n
> COP (0x16b2400) nextstate
> BINOP (0x16b23d8) sassign
> BINOP (0x16b23b0) add [5]
> BINOP (0x16b2368) modulo [4]
> UNOP (0x16b2328) null [15]
> PADOP (0x16b2308) gvsv GV (0x15a2150) *n
> SVOP (0x16b2348) const [7] IV (0x15a2180) 1000
> SVOP (0x16b2390) const [8] IV (0x1543bf8) 167772160
> UNOP (0x16b22e8) null [15]
> PADOP (0x16b22c8) gvsv GV (0x15a22b8) *result
>
> Use at least intops:
>
> $ perl -MO=Terse -Minteger -e '$n=1127;$result=($n%1000)+167772160;'
> LISTOP (0x16b2998) leave [1]
> OP (0x16b2b50) enter
> COP (0x16b2940) nextstate
> BINOP (0x16b2918) sassign
> SVOP (0x16b2340) const [6] IV (0x15a2210) 1127
> UNOP (0x16b2400) null [15]
> PADOP (0x16b21f0) gvsv GV (0x15a2288) *n
> COP (0x16b2af8) nextstate
> BINOP (0x16b2ad0) sassign
> BINOP (0x16b2aa8) i_add [5]
> BINOP (0x16b2a60) i_modulo [4]
> UNOP (0x16b2a20) null [15]
> PADOP (0x16b2a00) gvsv GV (0x15a2288) *n
> SVOP (0x16b2a40) const [7] IV (0x15a2198) 1000
> SVOP (0x16b2a88) const [8] IV (0x16c2aa0) 167772160
> UNOP (0x16b29e0) null [15]
> PADOP (0x16b29c0) gvsv GV (0x1543be0) *result
>
> Do some simple minor folding:
>
> $ perl -MO=Terse -e '$result=(1127%1000)+167772160;'
> LISTOP (0x16b2370) leave [1]
> OP (0x16b2398) enter
> COP (0x16b2328) nextstate
> BINOP (0x16b2300) sassign
> SVOP (0x16b22e0) const [4] IV (0x15a2270) 167772287
> UNOP (0x16b21f0) null [15]
> PADOP (0x16b21d0) gvsv GV (0x15a2150) *result
>
> And finally constant fold with symbols:
>
> $ perl -MO=Terse -Minteger -e 'use constant n=>1127;
> $result=(n%1000)+167772160;'
> LISTOP (0x13a0520) leave [1]
> OP (0x13786c0) enter
> COP (0x13a04c0) nextstate
> BINOP (0x13a0498) sassign
> SVOP (0x1378448) const [4] IV (0x13816a8) 167772287
> UNOP (0x1396920) null [15]
> PADOP (0x1396730) gvsv GV (0x13b09b8) *result
> --
> Reini Urban
>
>
>
Thread Previous