[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Avoiding redundant loads in jimple



Hi Saswat,

On Sun, 18 Jul 2004, Saswat Anand wrote:

> The pseudo-jimple code produced with default options is:
> {
>  $r0 = x.member;
>  $r0.fun();
>  $r1 = x.member;
>  $r1.fun();
> }
>
> Instead, I would prefer to have:
> {
>  $r0 = x.member;
>  $r0.fun();
>  $r0.fun();
> }

Common subexpression elimination can take care of this, but only if you
promise that x.member doesn't change.  In general you might not know that,
because fun() might have a side effect.  I think it does use a side-effect
tester, but one that's very naive.

> Also if I have:
> {
>  x.member = new Member();
>  x.member.fun();
> }
>
> I want to have:
> {
>  $r0 = new Member();
>  x.member = $r0;
>  $r0.fun();
> }
>
> instead of: (which soot produces)
> {
>  $r0 = new Member();
>  x.member = $r0;
>  $r1 = x.member;
>  $r1.fun();
> }

If you use the common subexpression eliminator (-p jop.cse on) that should
handle that case.

pat