do not generate zero divisor checks if a divisor is a constant

git-svn-id: trunk@27082 -
This commit is contained in:
Károly Balogh 2014-03-10 18:16:17 +00:00
parent 1e65caa37a
commit 075645d2b3

View File

@ -382,9 +382,12 @@ implementation
{ purposes }
hdenom := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
hlcg.a_load_loc_reg(current_asmdata.CurrAsmList,right.resultdef,osuinttype,right.location,hdenom);
{ verify if the divisor is zero, if so return an error
immediately
{ verify if the divisor is zero, if so return an error immediately,
except if we have a const node, where we don't need this, because
then zero check was done earlier.
}
if (right.nodetype <> ordconstn) then
begin
current_asmdata.getjumplabel(hl);
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,0,hdenom,hl);
paraloc1.init;
@ -395,6 +398,7 @@ implementation
cg.a_call_name(current_asmdata.CurrAsmList,'FPC_HANDLEERROR',false);
paraloc1.done;
cg.a_label(current_asmdata.CurrAsmList,hl);
end;
if nodetype = modn then
emit_mod_reg_reg(is_signed(left.resultdef),hdenom,hreg1)
else