|
@@ -761,7 +761,6 @@ implementation
|
|
hp : tnode;
|
|
hp : tnode;
|
|
rd,ld,nd : tdef;
|
|
rd,ld,nd : tdef;
|
|
hsym : tfieldvarsym;
|
|
hsym : tfieldvarsym;
|
|
- i : longint;
|
|
|
|
llow,lhigh,
|
|
llow,lhigh,
|
|
rlow,rhigh : tconstexprint;
|
|
rlow,rhigh : tconstexprint;
|
|
strtype : tstringtype;
|
|
strtype : tstringtype;
|
|
@@ -945,29 +944,6 @@ implementation
|
|
{ if both are orddefs then check sub types }
|
|
{ if both are orddefs then check sub types }
|
|
else if (ld.typ=orddef) and (rd.typ=orddef) then
|
|
else if (ld.typ=orddef) and (rd.typ=orddef) then
|
|
begin
|
|
begin
|
|
- { optimize multiplacation by a power of 2 }
|
|
|
|
- if not(cs_check_overflow in current_settings.localswitches) and
|
|
|
|
- (nodetype = muln) and
|
|
|
|
- (((left.nodetype = ordconstn) and
|
|
|
|
- ispowerof2(tordconstnode(left).value,i)) or
|
|
|
|
- ((right.nodetype = ordconstn) and
|
|
|
|
- ispowerof2(tordconstnode(right).value,i))) then
|
|
|
|
- begin
|
|
|
|
- if left.nodetype = ordconstn then
|
|
|
|
- begin
|
|
|
|
- tordconstnode(left).value := i;
|
|
|
|
- result := cshlshrnode.create(shln,right,left);
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- begin
|
|
|
|
- tordconstnode(right).value := i;
|
|
|
|
- result := cshlshrnode.create(shln,left,right);
|
|
|
|
- end;
|
|
|
|
- left := nil;
|
|
|
|
- right := nil;
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
{ set for & and | operations in macpas mode: they only work on }
|
|
{ set for & and | operations in macpas mode: they only work on }
|
|
{ booleans, and always short circuit evaluation }
|
|
{ booleans, and always short circuit evaluation }
|
|
if (nf_short_bool in flags) then
|
|
if (nf_short_bool in flags) then
|
|
@@ -2376,10 +2352,11 @@ implementation
|
|
{$ifdef addstringopt}
|
|
{$ifdef addstringopt}
|
|
hp : tnode;
|
|
hp : tnode;
|
|
{$endif addstringopt}
|
|
{$endif addstringopt}
|
|
- lt,rt : tnodetype;
|
|
|
|
rd,ld : tdef;
|
|
rd,ld : tdef;
|
|
newstatement : tstatementnode;
|
|
newstatement : tstatementnode;
|
|
temp : ttempcreatenode;
|
|
temp : ttempcreatenode;
|
|
|
|
+ i : longint;
|
|
|
|
+ lt,rt : tnodetype;
|
|
begin
|
|
begin
|
|
result:=nil;
|
|
result:=nil;
|
|
|
|
|
|
@@ -2422,6 +2399,29 @@ implementation
|
|
{ if both are orddefs then check sub types }
|
|
{ if both are orddefs then check sub types }
|
|
else if (ld.typ=orddef) and (rd.typ=orddef) then
|
|
else if (ld.typ=orddef) and (rd.typ=orddef) then
|
|
begin
|
|
begin
|
|
|
|
+ { optimize multiplacation by a power of 2 }
|
|
|
|
+ if not(cs_check_overflow in current_settings.localswitches) and
|
|
|
|
+ (nodetype = muln) and
|
|
|
|
+ (((left.nodetype = ordconstn) and
|
|
|
|
+ ispowerof2(tordconstnode(left).value,i)) or
|
|
|
|
+ ((right.nodetype = ordconstn) and
|
|
|
|
+ ispowerof2(tordconstnode(right).value,i))) then
|
|
|
|
+ begin
|
|
|
|
+ if left.nodetype = ordconstn then
|
|
|
|
+ begin
|
|
|
|
+ tordconstnode(left).value := i;
|
|
|
|
+ result := cshlshrnode.create(shln,right,left);
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ tordconstnode(right).value := i;
|
|
|
|
+ result := cshlshrnode.create(shln,left,right);
|
|
|
|
+ end;
|
|
|
|
+ left := nil;
|
|
|
|
+ right := nil;
|
|
|
|
+ exit;
|
|
|
|
+ end;
|
|
|
|
+
|
|
{ 2 booleans ? }
|
|
{ 2 booleans ? }
|
|
if is_boolean(ld) and is_boolean(rd) then
|
|
if is_boolean(ld) and is_boolean(rd) then
|
|
begin
|
|
begin
|