I am trying to figure out how many clock cycles or total instructions it takes to access a pointer in C. I dont think I know how to figure out for example, p->x = d->a + f->b
i would assume two loads per pointer, just guessing that there would be a load for the pointer, and a load for the value. So in this operations, the pointer resolution would be a much larger factor than the actual addition, as far as trying to speed this code up, right?
This may depend on the compiler and architecture implemented, but am I on the right track?
I have seen some code where each value used in say, 3 additions, came from a
f2->sum = p1->p2->p3->x + p1->p2->p3->a + p1->p2->p3->m
type of structure, and I am trying to define how bad this is
p3
into a register and use it for all 3 member accesses (assuming there's novolatile
members being used). – Amandine