Re:Does a compiler use all x86 instructions? (2010)
by efaref on Thursday August 25, 2016 @08:26AM
(#12358456)
Yes, I think it was designed in particular for determining addresses of fields within structures and variables on the stack, for example if you had:
struct foo
{
int field1;
int field2[10];
}
Then an access like: fooptr->field2[index]
Would compile to: fooptr + sizeof(int) * index + offsetof(struct foo, field2)
Which is: lea $4(fooptr,index,4)
Also Zen of Assembly mentions that LEA can store its result in any register and doesn't alter flags.