From 88279484af7827b14600169965c258de9372e72b Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Wed, 19 Oct 2016 20:01:19 -0500 Subject: [PATCH] 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.) --- DAG.pas | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/DAG.pas b/DAG.pas index e64e54b..243b991 100644 --- a/DAG.pas +++ b/DAG.pas @@ -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}