mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-26 03:18:32 +02:00
do not generate zero divisor checks if a divisor is a constant
git-svn-id: trunk@27082 -
This commit is contained in:
parent
1e65caa37a
commit
075645d2b3
@ -382,19 +382,23 @@ implementation
|
|||||||
{ purposes }
|
{ purposes }
|
||||||
hdenom := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
|
hdenom := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
|
||||||
hlcg.a_load_loc_reg(current_asmdata.CurrAsmList,right.resultdef,osuinttype,right.location,hdenom);
|
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
|
{ verify if the divisor is zero, if so return an error immediately,
|
||||||
immediately
|
except if we have a const node, where we don't need this, because
|
||||||
|
then zero check was done earlier.
|
||||||
}
|
}
|
||||||
current_asmdata.getjumplabel(hl);
|
if (right.nodetype <> ordconstn) then
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,0,hdenom,hl);
|
begin
|
||||||
paraloc1.init;
|
current_asmdata.getjumplabel(hl);
|
||||||
pd:=search_system_proc('fpc_handleerror');
|
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,0,hdenom,hl);
|
||||||
paramanager.getintparaloc(pd,1,paraloc1);
|
paraloc1.init;
|
||||||
cg.a_load_const_cgpara(current_asmdata.CurrAsmList,OS_S32,aint(200),paraloc1);
|
pd:=search_system_proc('fpc_handleerror');
|
||||||
paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
|
paramanager.getintparaloc(pd,1,paraloc1);
|
||||||
cg.a_call_name(current_asmdata.CurrAsmList,'FPC_HANDLEERROR',false);
|
cg.a_load_const_cgpara(current_asmdata.CurrAsmList,OS_S32,aint(200),paraloc1);
|
||||||
paraloc1.done;
|
paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
|
||||||
cg.a_label(current_asmdata.CurrAsmList,hl);
|
cg.a_call_name(current_asmdata.CurrAsmList,'FPC_HANDLEERROR',false);
|
||||||
|
paraloc1.done;
|
||||||
|
cg.a_label(current_asmdata.CurrAsmList,hl);
|
||||||
|
end;
|
||||||
if nodetype = modn then
|
if nodetype = modn then
|
||||||
emit_mod_reg_reg(is_signed(left.resultdef),hdenom,hreg1)
|
emit_mod_reg_reg(is_signed(left.resultdef),hdenom,hreg1)
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user