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

Reply via email to