mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 02:27:56 +02:00
* transform a/a only into 1 if fastmath is on
This commit is contained in:
parent
ffd14f449d
commit
09b435cdab
@ -1142,7 +1142,9 @@ implementation
|
||||
end;
|
||||
end
|
||||
{ optimize a/a and a-a }
|
||||
else if (cs_opt_level2 in current_settings.optimizerswitches) and (nodetype in [slashn,subn]) and
|
||||
else if (((cs_opt_level2 in current_settings.optimizerswitches) and (nodetype=subn)) or
|
||||
(([cs_opt_fastmath,cs_opt_level2]*current_settings.optimizerswitches=[cs_opt_fastmath,cs_opt_level2]) and (nodetype=slashn))
|
||||
) and
|
||||
left.isequal(right) and not(might_have_sideeffects(left,[mhs_exceptions])) then
|
||||
begin
|
||||
case nodetype of
|
||||
|
14
tests/tbs/tb0704.pp
Normal file
14
tests/tbs/tb0704.pp
Normal file
@ -0,0 +1,14 @@
|
||||
{ %opt=-Oonofastmath -CE -Oonoconstprop }
|
||||
{$mode objfpc}
|
||||
uses
|
||||
sysutils;
|
||||
var
|
||||
a : real;
|
||||
begin
|
||||
try
|
||||
writeln(a/a);
|
||||
except
|
||||
halt(0);
|
||||
end;
|
||||
halt(1);
|
||||
end.
|
14
tests/tbs/tb0705.pp
Normal file
14
tests/tbs/tb0705.pp
Normal file
@ -0,0 +1,14 @@
|
||||
{ %opt=-O4 -CE -Oonoconstprop }
|
||||
{$mode objfpc}
|
||||
uses
|
||||
sysutils;
|
||||
var
|
||||
a : real;
|
||||
begin
|
||||
try
|
||||
writeln(a/a);
|
||||
except
|
||||
halt(1);
|
||||
end;
|
||||
halt(0);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user