I haven't tried this, but I suspect a pointer analysis could help you obtain
a more general solution.  Take a look at ptranal.ml in the cil src/ext/pta
directory.  There will still be a lot of cases where this won't work though
(due, as Gabriel pointed out, to the undecidability of the problem in
general).
--Stephen

On Wed, Sep 9, 2009 at 2:42 AM, Gabriel Kerneis <kern...@pps.jussieu.fr>wrote:

> On Tue, Sep 08, 2009 at 10:33:46PM -0700, Benjamin Ylvisaker wrote:
> > Does anyone know if there is any existing optimization in Cil that
> > will do the translation of
> >
> >    int a;
> >    int *b = &a;
> >    *b = 4;
> >    ...
> >
> > into
> >
> >    int a;
> >    int *b = &a;
> >    a = 4;
> >    ...
> >
> > ?
>
> This is undecidable in the general case. But if you only need to match
> this very specific pattern (X = &Y; *X = ... ; => X = &Y; Y = ...;), it
> is straightforward to write a visitor performing the optimisation.
> Cil.peepHole2 is a generic function to do such things.
>
> Regards,
> --
> Gabriel Kerneis
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> CIL-users mailing list
> CIL-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/cil-users
>
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to