Menu ▾ ▴

#161 Improvement of partail evaluator

Some sunny day
open
None
6
2014-12-28
2014-12-15
No

In optimizing mode, when applying code/*, code like this :

public static int m(int a) {
    int b = a + 1;
    b = b + 2;
    return b;
}

is transformed to this:

public static int m(int a) {
    return a + 1 + 2;
}

Ideally the code would be transformed to return a + 3;
While not easy, it would be an evolution of constant propagation : do you plan such modification for ProGuard?

Discussion

  • Eric Lafortune

    Eric Lafortune - 2014-12-28

    Handling limited cases might be relatively easy through peephole optimizations. Respecting the constant sizes in the generated instructions would be the trickiest part.

    Handling the general case would indeed require extending the partial evaluator and related classes. Representing the expressions is easy, but applying the simplifications in the right places is not.

    I'll consider the peephole optimizations.

     
  • Eric Lafortune

    Eric Lafortune - 2014-12-28
    • assigned_to: Eric Lafortune
    • Priority: 5 --> 6
     

Log in to post a comment.