mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 11:45:32 +02:00
* the optimization of converting a multiplication with a power of two to
a shl is moved from n386add/secondpass to nadd/resulttypepass
This commit is contained in:
parent
185fa10345
commit
ed2bdb31a6
@ -1443,25 +1443,6 @@ interface
|
||||
{ the location.register will be filled in later (JM) }
|
||||
location_reset(location,LOC_REGISTER,OS_INT);
|
||||
|
||||
{$IfNDef NoShlMul}
|
||||
if right.nodetype=ordconstn then
|
||||
swapleftright;
|
||||
If (left.nodetype = ordconstn) and
|
||||
ispowerof2(tordconstnode(left).value, power) and
|
||||
not(cs_check_overflow in aktlocalswitches) then
|
||||
Begin
|
||||
{ This release will be moved after the next }
|
||||
{ instruction by the optimizer. No need to }
|
||||
{ release left.location, since it's a }
|
||||
{ constant (JM) }
|
||||
location_release(exprasmlist,right.location);
|
||||
location.register:=rg.getregisterint(exprasmlist);
|
||||
cg.a_load_loc_reg(exprasmlist,right.location,location.register);
|
||||
cg.a_op_const_reg(exprasmlist,OP_SHL,power,location.register);
|
||||
End
|
||||
Else
|
||||
Begin
|
||||
{$EndIf NoShlMul}
|
||||
regstopush := all_registers;
|
||||
remove_non_regvars_from_loc(right.location,regstopush);
|
||||
remove_non_regvars_from_loc(left.location,regstopush);
|
||||
@ -1511,9 +1492,6 @@ interface
|
||||
emit_reg(A_POP,S_L,R_EDX);
|
||||
if popeax then
|
||||
emit_reg(A_POP,S_L,R_EAX);
|
||||
{$IfNDef NoShlMul}
|
||||
End;
|
||||
{$endif NoShlMul}
|
||||
location_freetemp(exprasmlist,left.location);
|
||||
location_freetemp(exprasmlist,right.location);
|
||||
exit;
|
||||
@ -1573,7 +1551,11 @@ begin
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.44 2002-07-20 11:58:00 florian
|
||||
Revision 1.45 2002-07-26 11:17:52 jonas
|
||||
* the optimization of converting a multiplication with a power of two to
|
||||
a shl is moved from n386add/secondpass to nadd/resulttypepass
|
||||
|
||||
Revision 1.44 2002/07/20 11:58:00 florian
|
||||
* types.pas renamed to defbase.pas because D6 contains a types
|
||||
unit so this would conflicts if D6 programms are compiled
|
||||
+ Willamette/SSE2 instructions to assembler added
|
||||
|
@ -605,6 +605,29 @@ implementation
|
||||
{ if both are orddefs then check sub types }
|
||||
else if (ld.deftype=orddef) and (rd.deftype=orddef) then
|
||||
begin
|
||||
{ optimize multiplacation by a power of 2 }
|
||||
if not(cs_check_overflow in aktlocalswitches) 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? Make them equal to the largest boolean }
|
||||
if is_boolean(ld) and is_boolean(rd) then
|
||||
begin
|
||||
@ -1708,7 +1731,11 @@ begin
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.57 2002-07-23 13:08:16 jonas
|
||||
Revision 1.58 2002-07-26 11:17:52 jonas
|
||||
* the optimization of converting a multiplication with a power of two to
|
||||
a shl is moved from n386add/secondpass to nadd/resulttypepass
|
||||
|
||||
Revision 1.57 2002/07/23 13:08:16 jonas
|
||||
* fixed constant set evaluation of new set handling for non-commutative
|
||||
operators
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user