[cfe-dev] Adding constant optimizations to Clang AST

David Blaikie dblaikie at gmail.com
Wed Feb 6 13:12:33 PST 2013


On Wed, Feb 6, 2013 at 12:17 PM, dmanatunga <manatunga at gmail.com> wrote:
> I am working on implementing a constant reassociation optimization to the AST
> which will take an expression, such as:
> x = 10 + a + 5
> and reassociate it to some form of:
> x = 10 + 5 + a.

Why? LLVM optimizations will already do the right thing with this sort of code.

> Where would be the best place to apply this optimization? Should it be done
> through a plugin using a visitor (can plugins edit the AST before final
> compilation)? Or do I need to manually edit certain locations in the source
> code.

Are you trying to transform the user's code for them? (ie: do you
expect to modify the original source files or otherwise give this
source back to the user in some form) Or just produce better binaries?



More information about the cfe-dev mailing list