mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-01 19:42:40 +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 }
|
||||
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.
|
||||
}
|
||||
current_asmdata.getjumplabel(hl);
|
||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,0,hdenom,hl);
|
||||
paraloc1.init;
|
||||
pd:=search_system_proc('fpc_handleerror');
|
||||
paramanager.getintparaloc(pd,1,paraloc1);
|
||||
cg.a_load_const_cgpara(current_asmdata.CurrAsmList,OS_S32,aint(200),paraloc1);
|
||||
paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
|
||||
cg.a_call_name(current_asmdata.CurrAsmList,'FPC_HANDLEERROR',false);
|
||||
paraloc1.done;
|
||||
cg.a_label(current_asmdata.CurrAsmList,hl);
|
||||
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;
|
||||
pd:=search_system_proc('fpc_handleerror');
|
||||
paramanager.getintparaloc(pd,1,paraloc1);
|
||||
cg.a_load_const_cgpara(current_asmdata.CurrAsmList,OS_S32,aint(200),paraloc1);
|
||||
paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user