* convert <real x>*<real x> into sqr(<real x>), it might reduces register

pressure and/or memory accesses without a drawback

git-svn-id: trunk@18252 -
This commit is contained in:
florian 2011-08-17 16:00:16 +00:00
parent f6fbc17463
commit e796a878ca

View File

@ -748,12 +748,14 @@ implementation
exit; exit;
end; end;
{ slow simplifications }
if (cs_opt_level2 in current_settings.optimizerswitches) then
begin
{ the comparison is might be expensive and the nodes are usually only { the comparison is might be expensive and the nodes are usually only
equal if some previous optimizations were done so don't check equal if some previous optimizations were done so don't check
this simplification always this simplification always
} }
if (cs_opt_level2 in current_settings.optimizerswitches) and if is_boolean(left.resultdef) and is_boolean(right.resultdef) and
is_boolean(left.resultdef) and is_boolean(right.resultdef) and
{ since the expressions might have sideeffects, we may only remove them { since the expressions might have sideeffects, we may only remove them
if short boolean evaluation is turned on } if short boolean evaluation is turned on }
(nf_short_bool in flags) then (nf_short_bool in flags) then
@ -777,6 +779,17 @@ implementation
end; end;
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 }
if is_real(left.resultdef) and is_real(left.resultdef) and
left.isequal(right) then
begin
result:=cinlinenode.create(in_sqr_real,false,left);
left:=nil;
exit;
end;
end;
end; end;