Ensure % with negative operands is not mis-optimized in intermediate code.

This will not be triggered in most cases, but might be if one of the operand expressions was itself subject to optimization.
This commit is contained in:
Stephen Heumann
2018-09-14 19:16:50 -05:00
parent fedd275395
commit 80b96c1147

View File

@@ -1625,7 +1625,7 @@ case op^.opcode of {check for optimizations of this node}
pc_mdl: begin {pc_mdl} pc_mdl: begin {pc_mdl}
if op^.right^.opcode = pc_ldc then if op^.right^.opcode = pc_ldc then
if op^.left^.opcode = pc_ldc then if op^.left^.opcode = pc_ldc then
if op^.right^.lval <> 0 then begin if (op^.left^.lval >= 0) and (op^.right^.lval > 0) then begin
op^.left^.lval := op^.left^.lval mod op^.right^.lval; op^.left^.lval := op^.left^.lval mod op^.right^.lval;
opv := op^.left; opv := op^.left;
end; {if} end; {if}
@@ -1634,7 +1634,7 @@ case op^.opcode of {check for optimizations of this node}
pc_mod: begin {pc_mod} pc_mod: begin {pc_mod}
if op^.right^.opcode = pc_ldc then if op^.right^.opcode = pc_ldc then
if op^.left^.opcode = pc_ldc then if op^.left^.opcode = pc_ldc then
if op^.right^.q <> 0 then begin if (op^.left^.q >= 0) and (op^.right^.q > 0) then begin
op^.left^.q := op^.left^.q mod op^.right^.q; op^.left^.q := op^.left^.q mod op^.right^.q;
opv := op^.left; opv := op^.left;
end; {if} end; {if}