mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-08-15 22:28:29 +00:00
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:
4
DAG.pas
4
DAG.pas
@@ -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}
|
||||||
|
Reference in New Issue
Block a user