This is a suggestion for an optimisation technique.
(Thanks to Jude Nelson for bringing this to our attention)
void Do_Something_With_Triangle(PointType* triangle) {
triangle[0].x=1;
triangle[0].y=2;
//etc
}
This disassembled into this:
link a6,#0
move.l 8(a6),a0 ;I think 8(a6) is triangle...
moveq #0,d0
lsl 2,d0
lea 0(a0,d0),a0
move #1,(a0)
move.l 8(a6),a0
moveq #0,d0
lsl 2,d0
lea 0(a0,d0),a0
move #2,2(a0)
unlk a6
rts
Really, we should do some constant folding, since the
array index is a constant, as is the offset for the struct
member. We should be generating something like this:
move.l 8(a6), a0
move #1, (a0)
move.l 8(a6), a0
move #2, 2(a0)
Logged In: YES
user_id=583634
Originator: YES
Just to update...
I have a fix which improves this situation, but I'm not 100% happy with it, because it's not general enough, and still generates a suboptimal instruction sequence.
I'll try to rework it a little, see if I can improve it, and update again then.