[LLVMdev] Hoisting elements of array argument into registers
batterseapower at hotmail.com
Fri Nov 5 15:16:35 PDT 2010
Duncan Sands <baldrick <at> free.fr> writes:
> > I see the same with clang. I'm not sure why the optimizers do so much better
> > when they can see that sp is a local array (the special initial values don't
> > matter).
> It is the scalar replacement of aggregates pass that puts everything into
> registers when sp is a local array.
Yes, I had hoped that scalar replacement would get the array case. What
surprised me is that it didn't. However, I can reproduce your result (good
optimisation for g()) with LLVM HEAD. My earlier tests used "opt -O2", but
once I tried again with (HEAD) Clang -O3 I got an optimised g().
However, scalar replacement can't help with functions like a (non-inlined) wf()
where the structure of sp is unknown. Is there any hope for LLVM optimising
such functions? Some combination of passes that will do what I want? This
problem is essentially killing all opportunities for loop optimisation in
Haskell right now, so we would dearly like to have a solution :-)
More information about the llvm-dev