+ optimizations (at -O2 level) for (where 'a' is an integer expression, without

side effects):
  * a - a   -> 0
  * a xor a -> 0
  * a and a -> a
  * a or a  -> a
  * a <> a  -> false
  * a < a   -> false
  * a > a   -> false
  * a = a   -> true
  * a <= a  -> true
  * a >= a  -> true

git-svn-id: trunk@36027 -
This commit is contained in:
nickysn 2017-05-01 10:17:50 +00:00
parent ed984e0c76
commit 5aeb73b940

View File

@ -1012,7 +1012,39 @@ implementation
end;
end;
end
end;
end;
if is_integer(left.resultdef) and is_integer(right.resultdef) then
begin
if not might_have_sideeffects(left) and
left.isequal(right) then
begin
case nodetype of
andn,orn:
begin
result:=left;
left:=nil;
exit;
end;
xorn,
subn,
unequaln,
ltn,
gtn:
begin
result:=cordconstnode.create(0,resultdef,true);
exit;
end;
equaln,
lten,
gten:
begin
result:=cordconstnode.create(0,resultdef,true);
exit;
end;
end;
end;
end;
{ using sqr(x) for reals instead of x*x might reduces register pressure and/or
memory accesses while sqr(<real>) has no drawback }