* 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,35 +748,48 @@ implementation
exit; exit;
end; end;
{ the comparison is might be expensive and the nodes are usually only { slow simplifications }
equal if some previous optimizations were done so don't check if (cs_opt_level2 in current_settings.optimizerswitches) then
this simplification always begin
} { the comparison is might be expensive and the nodes are usually only
if (cs_opt_level2 in current_settings.optimizerswitches) and equal if some previous optimizations were done so don't check
is_boolean(left.resultdef) and is_boolean(right.resultdef) and this simplification always
{ since the expressions might have sideeffects, we may only remove them }
if short boolean evaluation is turned on } if is_boolean(left.resultdef) and is_boolean(right.resultdef) and
(nf_short_bool in flags) then { since the expressions might have sideeffects, we may only remove them
begin if short boolean evaluation is turned on }
if left.isequal(right) then (nf_short_bool in flags) then
begin begin
case nodetype of if left.isequal(right) then
andn,orn: begin
begin case nodetype of
result:=left; andn,orn:
left:=nil; begin
exit; result:=left;
end; left:=nil;
{ exit;
xorn: end;
begin {
result:=cordconstnode.create(0,resultdef,true); xorn:
exit; begin
end; result:=cordconstnode.create(0,resultdef,true);
} exit;
end;
}
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;