summaryrefslogtreecommitdiff
path: root/compiler/i8086/cgcpu.pas
diff options
context:
space:
mode:
authornickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2>2014-01-01 14:57:44 +0000
committernickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2>2014-01-01 14:57:44 +0000
commit93c2e74493be1fdfd34d33d5078c710826a0840d (patch)
treeadef40de7a920d4a5a91f15637362fb1ce07fe71 /compiler/i8086/cgcpu.pas
parent383ed1faf2d8944173854b8bf2c731e9ff8f2681 (diff)
downloadfpc-93c2e74493be1fdfd34d33d5078c710826a0840d.tar.gz
* tcg8086.a_op_const_reg: perform the OP_AND, OP_OR and OP_XOR optimizations for
$0000 and $FFFF values on the low and the high words independently. git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@26344 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/i8086/cgcpu.pas')
-rw-r--r--compiler/i8086/cgcpu.pas54
1 files changed, 44 insertions, 10 deletions
diff --git a/compiler/i8086/cgcpu.pas b/compiler/i8086/cgcpu.pas
index db28e17ef3..5efb1bc6a4 100644
--- a/compiler/i8086/cgcpu.pas
+++ b/compiler/i8086/cgcpu.pas
@@ -308,27 +308,61 @@ unit cgcpu;
end;
OP_AND, OP_OR, OP_XOR:
begin
- if longword(a) = high(longword) then
+ { low word operation }
+ if aint(a and $FFFF) = aint(0) then
begin
case op of
OP_AND:
- exit;
+ a_load_const_reg(list,OS_16,aint(0),reg);
+ OP_OR,OP_XOR:
+ {do nothing};
+ else
+ InternalError(2013100701);
+ end;
+ end
+ else if aint(a and $FFFF) = aint($FFFF) then
+ begin
+ case op of
+ OP_AND:
+ {do nothing};
OP_OR:
- a_load_const_reg(list,size,high(longword),reg);
+ a_load_const_reg(list,OS_16,aint($FFFF),reg);
OP_XOR:
- begin
- list.concat(taicpu.op_reg(A_NOT,S_W,reg));
- list.concat(taicpu.op_reg(A_NOT,S_W,GetNextReg(reg)));
- end;
+ list.concat(taicpu.op_reg(A_NOT,S_W,reg));
else
InternalError(2013100701);
- end
+ end;
end
else
- begin
a_op_const_reg(list,op,OS_16,aint(a and $FFFF),reg);
+
+ { high word operation }
+ if aint(a shr 16) = aint(0) then
+ begin
+ case op of
+ OP_AND:
+ a_load_const_reg(list,OS_16,aint(0),GetNextReg(reg));
+ OP_OR,OP_XOR:
+ {do nothing};
+ else
+ InternalError(2013100701);
+ end;
+ end
+ else if aint(a shr 16) = aint($FFFF) then
+ begin
+ case op of
+ OP_AND:
+ {do nothing};
+ OP_OR:
+ a_load_const_reg(list,OS_16,aint($FFFF),GetNextReg(reg));
+ OP_XOR:
+ list.concat(taicpu.op_reg(A_NOT,S_W,GetNextReg(reg)));
+ else
+ InternalError(2013100701);
+ end;
+ end
+ else
a_op_const_reg(list,op,OS_16,aint(a shr 16),GetNextReg(reg));
- end;
end;
OP_SHR,OP_SHL,OP_SAR:
begin