|
@@ -162,17 +162,17 @@ implementation
|
|
if nf_isomod in flags then
|
|
if nf_isomod in flags then
|
|
begin
|
|
begin
|
|
if lv>=0 then
|
|
if lv>=0 then
|
|
- result:=create_simplified_ord_const(lv mod rv,resultdef,forinline)
|
|
|
|
|
|
+ result:=create_simplified_ord_const(lv mod rv,resultdef,forinline,false)
|
|
else
|
|
else
|
|
if ((-lv) mod rv)=0 then
|
|
if ((-lv) mod rv)=0 then
|
|
- result:=create_simplified_ord_const((-lv) mod rv,resultdef,forinline)
|
|
|
|
|
|
+ result:=create_simplified_ord_const((-lv) mod rv,resultdef,forinline,false)
|
|
else
|
|
else
|
|
- result:=create_simplified_ord_const(rv-((-lv) mod rv),resultdef,forinline);
|
|
|
|
|
|
+ result:=create_simplified_ord_const(rv-((-lv) mod rv),resultdef,forinline,false);
|
|
end
|
|
end
|
|
else
|
|
else
|
|
- result:=create_simplified_ord_const(lv mod rv,resultdef,forinline);
|
|
|
|
|
|
+ result:=create_simplified_ord_const(lv mod rv,resultdef,forinline,false);
|
|
divn:
|
|
divn:
|
|
- result:=create_simplified_ord_const(lv div rv,resultdef,forinline);
|
|
|
|
|
|
+ result:=create_simplified_ord_const(lv div rv,resultdef,forinline,cs_check_overflow in localswitches);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -705,30 +705,32 @@ implementation
|
|
rvalue:=tordconstnode(right).value;
|
|
rvalue:=tordconstnode(right).value;
|
|
if is_constintnode(left) then
|
|
if is_constintnode(left) then
|
|
begin
|
|
begin
|
|
|
|
+ lvalue:=tordconstnode(left).value;
|
|
|
|
+ case nodetype of
|
|
|
|
+ shrn:
|
|
|
|
+ lvalue:=tordconstnode(left).value shr rvalue;
|
|
|
|
+ shln:
|
|
|
|
+ lvalue:=tordconstnode(left).value shl rvalue;
|
|
|
|
+ else
|
|
|
|
+ internalerror(2019050517);
|
|
|
|
+ end;
|
|
if forinline then
|
|
if forinline then
|
|
begin
|
|
begin
|
|
{ shl/shr are unsigned operations, so cut off upper bits }
|
|
{ shl/shr are unsigned operations, so cut off upper bits }
|
|
case resultdef.size of
|
|
case resultdef.size of
|
|
1:
|
|
1:
|
|
- lvalue:=tordconstnode(left).value and byte($ff);
|
|
|
|
|
|
+ lvalue:=lvalue and byte($ff);
|
|
2:
|
|
2:
|
|
- lvalue:=tordconstnode(left).value and word($ffff);
|
|
|
|
|
|
+ lvalue:=lvalue and word($ffff);
|
|
4:
|
|
4:
|
|
- lvalue:=tordconstnode(left).value and dword($ffffffff);
|
|
|
|
|
|
+ lvalue:=lvalue and dword($ffffffff);
|
|
8:
|
|
8:
|
|
- lvalue:=tordconstnode(left).value and qword($ffffffffffffffff);
|
|
|
|
|
|
+ lvalue:=lvalue and qword($ffffffffffffffff);
|
|
else
|
|
else
|
|
internalerror(2013122301);
|
|
internalerror(2013122301);
|
|
end;
|
|
end;
|
|
- end
|
|
|
|
- else
|
|
|
|
- lvalue:=tordconstnode(left).value;
|
|
|
|
- case nodetype of
|
|
|
|
- shrn:
|
|
|
|
- result:=create_simplified_ord_const(lvalue shr rvalue,resultdef,forinline);
|
|
|
|
- shln:
|
|
|
|
- result:=create_simplified_ord_const(lvalue shl rvalue,resultdef,forinline);
|
|
|
|
- end;
|
|
|
|
|
|
+ end;
|
|
|
|
+ result:=create_simplified_ord_const(lvalue,resultdef,forinline,false);
|
|
end
|
|
end
|
|
else if rvalue=0 then
|
|
else if rvalue=0 then
|
|
begin
|
|
begin
|
|
@@ -739,19 +741,22 @@ implementation
|
|
else if is_constintnode(left) then
|
|
else if is_constintnode(left) then
|
|
begin
|
|
begin
|
|
lvalue:=tordconstnode(left).value;
|
|
lvalue:=tordconstnode(left).value;
|
|
- { shl/shr are unsigned operations, so cut off upper bits }
|
|
|
|
- case resultdef.size of
|
|
|
|
- 1:
|
|
|
|
- lvalue:=tordconstnode(left).value and byte($ff);
|
|
|
|
- 2:
|
|
|
|
- lvalue:=tordconstnode(left).value and word($ffff);
|
|
|
|
- 4:
|
|
|
|
- lvalue:=tordconstnode(left).value and dword($ffffffff);
|
|
|
|
- 8:
|
|
|
|
- lvalue:=tordconstnode(left).value and qword($ffffffffffffffff);
|
|
|
|
- else
|
|
|
|
- internalerror(2013122301);
|
|
|
|
- end;
|
|
|
|
|
|
+ if forinline then
|
|
|
|
+ begin
|
|
|
|
+ { shl/shr are unsigned operations, so cut off upper bits }
|
|
|
|
+ case resultdef.size of
|
|
|
|
+ 1:
|
|
|
|
+ lvalue:=tordconstnode(left).value and byte($ff);
|
|
|
|
+ 2:
|
|
|
|
+ lvalue:=tordconstnode(left).value and word($ffff);
|
|
|
|
+ 4:
|
|
|
|
+ lvalue:=tordconstnode(left).value and dword($ffffffff);
|
|
|
|
+ 8:
|
|
|
|
+ lvalue:=tordconstnode(left).value and qword($ffffffffffffffff);
|
|
|
|
+ else
|
|
|
|
+ internalerror(2013122301);
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
{ '0 shl x' and '0 shr x' are 0 }
|
|
{ '0 shl x' and '0 shr x' are 0 }
|
|
if (lvalue=0) and
|
|
if (lvalue=0) and
|
|
((cs_opt_level4 in current_settings.optimizerswitches) or
|
|
((cs_opt_level4 in current_settings.optimizerswitches) or
|
|
@@ -878,8 +883,6 @@ implementation
|
|
|
|
|
|
|
|
|
|
function tshlshrnode.pass_1 : tnode;
|
|
function tshlshrnode.pass_1 : tnode;
|
|
- var
|
|
|
|
- regs : longint;
|
|
|
|
begin
|
|
begin
|
|
result:=nil;
|
|
result:=nil;
|
|
firstpass(left);
|
|
firstpass(left);
|
|
@@ -888,23 +891,11 @@ implementation
|
|
exit;
|
|
exit;
|
|
|
|
|
|
{$ifndef cpu64bitalu}
|
|
{$ifndef cpu64bitalu}
|
|
|
|
+ expectloc:=LOC_REGISTER;
|
|
{ 64 bit ints have their own shift handling }
|
|
{ 64 bit ints have their own shift handling }
|
|
if is_64bit(left.resultdef) then
|
|
if is_64bit(left.resultdef) then
|
|
- begin
|
|
|
|
- result := first_shlshr64bitint;
|
|
|
|
- if assigned(result) then
|
|
|
|
- exit;
|
|
|
|
- regs:=2;
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
|
|
+ result := first_shlshr64bitint;
|
|
{$endif not cpu64bitalu}
|
|
{$endif not cpu64bitalu}
|
|
- begin
|
|
|
|
- regs:=1
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
- if (right.nodetype<>ordconstn) then
|
|
|
|
- inc(regs);
|
|
|
|
- expectloc:=LOC_REGISTER;
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -924,7 +915,7 @@ implementation
|
|
{ constant folding }
|
|
{ constant folding }
|
|
if is_constintnode(left) then
|
|
if is_constintnode(left) then
|
|
begin
|
|
begin
|
|
- result:=create_simplified_ord_const(-tordconstnode(left).value,resultdef,forinline);
|
|
|
|
|
|
+ result:=create_simplified_ord_const(-tordconstnode(left).value,resultdef,forinline,cs_check_overflow in localswitches);
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
if is_constrealnode(left) then
|
|
if is_constrealnode(left) then
|