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