* More efficient if-statement construction in tmoddivnode.simplify

This commit is contained in:
J. Gareth "Curious Kit" Moreton 2023-05-11 19:13:11 +01:00 committed by FPK
parent 40072fb762
commit 0943458713

View File

@ -178,32 +178,33 @@ implementation
Result:=ctypeconvnode.create_internal(Result,resultdef); Result:=ctypeconvnode.create_internal(Result,resultdef);
exit; exit;
end; end;
end;
if is_constintnode(right) and is_constintnode(left) then
begin
rv:=tordconstnode(right).value;
lv:=tordconstnode(left).value;
case nodetype of if is_constintnode(left) then
modn: begin
if nf_isomod in flags then rv:=tordconstnode(right).value;
begin lv:=tordconstnode(left).value;
if lv>=0 then
result:=create_simplified_ord_const(lv mod rv,resultdef,forinline,false) case nodetype of
modn:
if nf_isomod in flags then
begin
if lv>=0 then
result:=create_simplified_ord_const(lv mod rv,resultdef,forinline,false)
else
if ((-lv) mod rv)=0 then
result:=create_simplified_ord_const((-lv) mod rv,resultdef,forinline,false)
else
result:=create_simplified_ord_const(rv-((-lv) mod rv),resultdef,forinline,false);
end
else else
if ((-lv) mod rv)=0 then result:=create_simplified_ord_const(lv mod rv,resultdef,forinline,false);
result:=create_simplified_ord_const((-lv) mod rv,resultdef,forinline,false) divn:
else result:=create_simplified_ord_const(lv div rv,resultdef,forinline,cs_check_overflow in localswitches);
result:=create_simplified_ord_const(rv-((-lv) mod rv),resultdef,forinline,false); else
end internalerror(2019050519);
else end;
result:=create_simplified_ord_const(lv mod rv,resultdef,forinline,false); end;
divn: end;
result:=create_simplified_ord_const(lv div rv,resultdef,forinline,cs_check_overflow in localswitches);
else
internalerror(2019050519);
end;
end;
end; end;