mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 18:09:30 +02:00
+ 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:
parent
ed984e0c76
commit
5aeb73b940
@ -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 }
|
||||
|
Loading…
Reference in New Issue
Block a user