[LLVMdev] which pass for optimizing access to a global struct?

Duncan Sands baldrick at free.fr
Tue May 17 23:04:31 PDT 2011


Hi Jochen,

> which pass do you recommend to optimize access to a global
> struct? for example:
>
> struct
> {
> int a;
> int b;
> } global;
>
> void foo(int x)
> {
>       global.a = x;
>       int y = global.a; // should be replaced by int y = x;
> }

the global value numbering (gvn) pass can do this, as can the instruction
combiner (-instcombine).  Maybe there are some others too.

Ciao, Duncan.

>
> I guess it's one of the alias passes but which one to choose?
> Thanks,
> -Jochen
>
> _______________________________________________
> 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