[LLVMdev] optimizing references within a struct

reed kotler rkotler at mips.com
Thu Feb 7 16:56:25 PST 2013


There is an optimization which the Greenhills compiler does for mips16.

I have not looked at it myself ,but it was recounted to me.

The basic idea is that if you have a large struct,  rather than 
reference each element from the base of the struct, it's possible to 
chose some optimal point(s) that are not at the beginning of the struct 
and use as the base to reference elements of the struct.

This particularly occurs in some of the codec code where there are large 
structs with many fields.

This allows them to use shorter versions of some of the instructions.
There are many 16/32 bit pairs of instructions in mips16, with the 
difference being the magnitude of the offset.

Some have 5 bit fields that are shifted left 2 bits, yielding an 
effective 128 byte offset.

There are lots of ways to optimize this problem.

You can for example keep moving the base pointer, have more than one 
base pointer, etc.

Is there such optimization already built into llvm?

Tia.

Reed




More information about the llvm-dev mailing list