mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 13:06:18 +02:00
+ optimize comparisons of constant pointers
git-svn-id: trunk@47031 -
This commit is contained in:
parent
af20b064ed
commit
65047cecdb
@ -506,6 +506,7 @@ implementation
|
|||||||
b : boolean;
|
b : boolean;
|
||||||
cr, cl : Tconstexprint;
|
cr, cl : Tconstexprint;
|
||||||
v2p, c2p, c1p, v1p: pnode;
|
v2p, c2p, c1p, v1p: pnode;
|
||||||
|
p1,p2: TConstPtrUInt;
|
||||||
begin
|
begin
|
||||||
result:=nil;
|
result:=nil;
|
||||||
l1:=0;
|
l1:=0;
|
||||||
@ -1330,6 +1331,33 @@ implementation
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if is_constpointernode(left) and is_constpointernode(right) then
|
||||||
|
begin
|
||||||
|
p1:=0;
|
||||||
|
p2:=0;
|
||||||
|
if left.nodetype=pointerconstn then
|
||||||
|
p1:=tpointerconstnode(left).value;
|
||||||
|
if right.nodetype=pointerconstn then
|
||||||
|
p2:=tpointerconstnode(right).value;
|
||||||
|
case nodetype of
|
||||||
|
equaln:
|
||||||
|
result:=cordconstnode.create(ord(p1=p2),bool8type,false);
|
||||||
|
unequaln:
|
||||||
|
result:=cordconstnode.create(ord(p1<>p2),bool8type,false);
|
||||||
|
gtn:
|
||||||
|
result:=cordconstnode.create(ord(p1>p2),bool8type,false);
|
||||||
|
ltn:
|
||||||
|
result:=cordconstnode.create(ord(p1<p2),bool8type,false);
|
||||||
|
gten:
|
||||||
|
result:=cordconstnode.create(ord(p1>=p2),bool8type,false);
|
||||||
|
lten:
|
||||||
|
result:=cordconstnode.create(ord(p1<=p2),bool8type,false);
|
||||||
|
else
|
||||||
|
Internalerror(2020100101);
|
||||||
|
end;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
{ slow simplifications }
|
{ slow simplifications }
|
||||||
if cs_opt_level2 in current_settings.optimizerswitches then
|
if cs_opt_level2 in current_settings.optimizerswitches then
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user