diff --git a/DAG.pas b/DAG.pas index 51f8a88..784057b 100644 --- a/DAG.pas +++ b/DAG.pas @@ -1638,7 +1638,13 @@ case op^.opcode of {check for optimizations of this node} pc_mdl: begin {pc_mdl} if op^.right^.opcode = pc_ldc then - if op^.left^.opcode = pc_ldc then + if op^.right^.lval = 1 then begin + if not SideEffects(op^.left) then begin + op^.right^.lval := 0; + opv := op^.right; + end; {if} + end {if} + else if op^.left^.opcode = pc_ldc then if (op^.left^.lval >= 0) and (op^.right^.lval > 0) then begin op^.left^.lval := op^.left^.lval mod op^.right^.lval; opv := op^.left; @@ -1647,7 +1653,13 @@ case op^.opcode of {check for optimizations of this node} pc_mod: begin {pc_mod} if op^.right^.opcode = pc_ldc then - if op^.left^.opcode = pc_ldc then + if op^.right^.q = 1 then begin + if not SideEffects(op^.left) then begin + op^.right^.q := 0; + opv := op^.right; + end; {if} + end {if} + else if op^.left^.opcode = pc_ldc then if (op^.left^.q >= 0) and (op^.right^.q > 0) then begin op^.left^.q := op^.left^.q mod op^.right^.q; opv := op^.left; @@ -2145,7 +2157,13 @@ case op^.opcode of {check for optimizations of this node} pc_uim: begin {pc_uim} if op^.right^.opcode = pc_ldc then - if op^.left^.opcode = pc_ldc then + if op^.right^.q = 1 then begin + if not SideEffects(op^.left) then begin + op^.right^.q := 0; + opv := op^.right; + end; {if} + end {if} + else if op^.left^.opcode = pc_ldc then if op^.right^.q <> 0 then begin op^.left^.q := ord(umod(op^.left^.q & $0000FFFF, op^.right^.q & $0000FFFF)); @@ -2170,7 +2188,13 @@ case op^.opcode of {check for optimizations of this node} pc_ulm: begin {pc_ulm} if op^.right^.opcode = pc_ldc then - if op^.left^.opcode = pc_ldc then + if op^.right^.lval = 1 then begin + if not SideEffects(op^.left) then begin + op^.right^.lval := 0; + opv := op^.right; + end; {if} + end {if} + else if op^.left^.opcode = pc_ldc then if op^.right^.lval <> 0 then begin op^.left^.lval := umod(op^.left^.lval, op^.right^.lval); opv := op^.left;