mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-09 10:48:30 +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;
|
||||
cr, cl : Tconstexprint;
|
||||
v2p, c2p, c1p, v1p: pnode;
|
||||
p1,p2: TConstPtrUInt;
|
||||
begin
|
||||
result:=nil;
|
||||
l1:=0;
|
||||
@ -1330,6 +1331,33 @@ implementation
|
||||
exit;
|
||||
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 }
|
||||
if cs_opt_level2 in current_settings.optimizerswitches then
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user