[LLVMdev] mem2reg optimization

Nicolas Capens nicolas.capens at gmail.com
Fri Sep 26 15:47:43 PDT 2008


Hi Andrew,

I can't see any reason not to run mem2reg as the first pass (except  
maybe run a CFG simplify first, which doesn't alter the use list as  
far as I know). Also, I doubt that any pass can actually make a valid  
change in the order of loads and stores. And finally, why would any  
pass want to change the order of the use list in the first place?

Only passes that create new stores and/or loads and don't insert them  
into the use list in the same reverse order could cause problems. But  
as far as I know that's only during codegen (e.g. specific  
instructions that need an operand to be in memory, and spills and  
loads added during register allocation).

Anyway, my experience with LLVM is quite limited so I might be  
overlooking something important. So if Dave's solution works in all  
cases and has comparable performance then that's obviously better.  
I'll try to compare performance early next week and keep you posted.

Kind regards,

Nicolas


On 26 Sep 2008, at 17:56, "Andrew Lenharth" <andrewl at lenharth.org>  
wrote:

> On Fri, Sep 26, 2008 at 10:41 AM, David Greene <dag at cray.com> wrote:
>> On Thursday 25 September 2008 13:15, David Greene wrote:
>>> I like your approach of using the use lists but I'm not sure the  
>>> ordering
>>> is guaranteed.  If it is, your approach is superior.
>>
>> I got my patch updated to work with TOT.  Here it is.  Comments  
>> welcome.
>> I still prefer Nicolas' solution if his use list ordering  
>> assumption is valid.
>
> Isn't the ordering an artifact of the creation of the users?  If you
> run mem2reg after other optimizations, why would you still have any
> ordering guarantees?
>
> Andrew
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



More information about the llvm-dev mailing list