mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-29 01:28:34 +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,9 +382,12 @@ 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.
|
||||||
}
|
}
|
||||||
|
if (right.nodetype <> ordconstn) then
|
||||||
|
begin
|
||||||
current_asmdata.getjumplabel(hl);
|
current_asmdata.getjumplabel(hl);
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,0,hdenom,hl);
|
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,0,hdenom,hl);
|
||||||
paraloc1.init;
|
paraloc1.init;
|
||||||
@ -395,6 +398,7 @@ implementation
|
|||||||
cg.a_call_name(current_asmdata.CurrAsmList,'FPC_HANDLEERROR',false);
|
cg.a_call_name(current_asmdata.CurrAsmList,'FPC_HANDLEERROR',false);
|
||||||
paraloc1.done;
|
paraloc1.done;
|
||||||
cg.a_label(current_asmdata.CurrAsmList,hl);
|
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