mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-12-30 14:31:04 +00:00
Small new optimization: "anything % 1" equals 0.
This commit is contained in:
parent
8078675aae
commit
895d0585a8
32
DAG.pas
32
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;
|
||||
|
Loading…
Reference in New Issue
Block a user