Generate better code when accessing structs and unions within other structures.

This cuts a few instructions from code like what is shown in commit affbe9. (It also works around the bug with that example, although that patch addresses the root cause of the problem.)
This commit is contained in:
Stephen Heumann 2016-10-19 20:01:19 -05:00
parent efb23003f7
commit 88279484af
1 changed files with 9 additions and 0 deletions

View File

@ -1431,6 +1431,15 @@ case op^.opcode of {check for optimizations of this node}
op^.left^.optype := op^.optype;
op^.left^.q := op^.left^.q + op^.q;
opv := op^.left;
end {else if}
else if opcode = pc_inc then begin
if op^.left^.optype = cgULong then begin
if ord4(op^.left^.q) + ord4(op^.q) < ord4(maxint - 1) then begin
op^.q := op^.q + op^.left^.q;
op^.left := op^.left^.left;
PeepHoleOptimization(opv);
end; {if}
end; {if}
end; {else if}
end; {case pc_ind}