mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-12-22 23:29:27 +00:00
New optimization: Use unsigned rather than signed comparisons in some cases involving values that were originally unsigned bytes.
Specifically, convert signed word comparisons to unsigned if both sides were either unsigned byte values or non-negative constants. This is incorporated as part of intermediate code peephole optimization (bit 0). This should alleviate some cases of performance regressions due to promoting char to int instead of unsigned int.
This commit is contained in:
parent
ab51fc228d
commit
5ab7c7876b
19
DAG.pas
19
DAG.pas
@ -26,6 +26,9 @@ procedure DAG (code: icptr);
|
|||||||
{ parameters: }
|
{ parameters: }
|
||||||
{ code - opcode }
|
{ code - opcode }
|
||||||
|
|
||||||
|
|
||||||
|
function TypeOf (op: icptr): baseTypeEnum;
|
||||||
|
|
||||||
{---------------------------------------------------------------}
|
{---------------------------------------------------------------}
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -1493,14 +1496,22 @@ case op^.opcode of {check for optimizations of this node}
|
|||||||
end; {else if}
|
end; {else if}
|
||||||
end; {case pc_ixa}
|
end; {case pc_ixa}
|
||||||
|
|
||||||
pc_leq: begin {pc_leq}
|
pc_leq, pc_les, pc_geq, pc_grt: begin {pc_leq, pc_les, pc_geq, pc_grt}
|
||||||
if op^.optype in [cgWord,cgUWord] then
|
if (op^.opcode = pc_leq) and (op^.optype in [cgWord,cgUWord]) then
|
||||||
if op^.right^.opcode = pc_ldc then
|
if op^.right^.opcode = pc_ldc then
|
||||||
if op^.right^.q < maxint then begin
|
if op^.right^.q < maxint then begin
|
||||||
op^.right^.q := op^.right^.q + 1;
|
op^.right^.q := op^.right^.q + 1;
|
||||||
op^.opcode := pc_les;
|
op^.opcode := pc_les;
|
||||||
end; {if}
|
end; {if}
|
||||||
end; {case pc_lnm}
|
if (op^.optype = cgWord) then
|
||||||
|
if (TypeOf(op^.right) = cgUByte)
|
||||||
|
or ((op^.right^.opcode = pc_ldc) and (op^.right^.q >= 0)
|
||||||
|
and (op^.right^.optype in [cgByte,cgUByte,cgWord])) then
|
||||||
|
if (TypeOf(op^.left) = cgUByte)
|
||||||
|
or ((op^.left^.opcode = pc_ldc) and (op^.left^.q >= 0)
|
||||||
|
and (op^.left^.optype in [cgByte,cgUByte,cgWord])) then
|
||||||
|
op^.optype := cgUWord;
|
||||||
|
end; {case pc_leq, pc_les, pc_geq, pc_grt}
|
||||||
|
|
||||||
pc_lnd: begin {pc_lnd}
|
pc_lnd: begin {pc_lnd}
|
||||||
if op^.right^.opcode = pc_ldc then begin
|
if op^.right^.opcode = pc_ldc then begin
|
||||||
@ -2168,7 +2179,7 @@ while list <> nil do begin
|
|||||||
end; {Member}
|
end; {Member}
|
||||||
|
|
||||||
|
|
||||||
function TypeOf (op: icptr): baseTypeEnum;
|
function TypeOf {(op: icptr): baseTypeEnum};
|
||||||
|
|
||||||
{ find the type for the expression tree }
|
{ find the type for the expression tree }
|
||||||
{ }
|
{ }
|
||||||
|
Loading…
Reference in New Issue
Block a user