[LLVMdev] Additional Optimization I'm Missing?

Dale Johannesen dalej at apple.com
Mon Mar 31 17:10:29 PDT 2008


On Mar 31, 2008, at 4:46 PM, Bobby Powers wrote:

> Hello, I'm working on using the LLVM JIT for a little project of  
> mine, amazing work first off!  I have a question about optimization  
> passes.  I initially have this function I've created, in python it  
> looks like this:
>
> OS_end = 50
> OS_start = 0
> OS_timestep = 1
> birth_rate = .3
> population = 30.0
>
> for time in range(OS_start, OS_end, OS_timestep):
>     births = birth_rate * population
>     deaths = 0.1 * population
>     population_NEXT = population + births - deaths
>
>
> The thing is, in forbody it is still doing:
> subtmp = population + (population * .3) - (population * .1)
>
>
> ideally I would love to see it reduced to:
> subtmp = 1.2 * population

This transformation changes the result due to roundoff errors, and  
would be incorrect.
In C using %lf the printed values of the 2 expressions diverge on the  
84th iteration.

> I've played around with adding a bunch of optimizations that sound  
> good from [http://www.llvm.org/docs/Passes.html], but I must admit  
> I'm a bit over my head here.  Does anyone have any suggestions?  Am  
> I missing passes, do I need to restructure the IR, or am I missing  
> some concept?
>
> thanks! (keep up the amazing work)
> yours,
> Bobby Powers
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080331/d85f26a1/attachment.html>


More information about the llvm-dev mailing list