mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-05 11:38:19 +02:00
* transform -1-x into not(x)
This commit is contained in:
parent
5086cf7e72
commit
594d4cc4f9
@ -916,8 +916,15 @@ implementation
|
||||
{ Deal with anti-commutative subtraction }
|
||||
if (nodetype = subn) then
|
||||
begin
|
||||
{ transform -1-x into not(x) }
|
||||
if is_signed(rd) and is_constintnode(left) and (tordconstnode(left).value=-1) then
|
||||
begin
|
||||
result:=cnotnode.create(right.getcopy);
|
||||
exit;
|
||||
end
|
||||
|
||||
{ change "0 - val" to "-val" }
|
||||
if is_constintnode(left) and (is_integer(right.resultdef) or is_pointer(right.resultdef)) then
|
||||
else if is_constintnode(left) and (is_integer(right.resultdef) or is_pointer(right.resultdef)) then
|
||||
begin
|
||||
if (tordconstnode(left).value = 0) then
|
||||
result := ctypeconvnode.create_internal(cunaryminusnode.create(right.getcopy),right.resultdef);
|
||||
|
@ -1,3 +1,4 @@
|
||||
{ %opt=-O- -O1 }
|
||||
var
|
||||
l : longint;
|
||||
|
||||
@ -11,5 +12,8 @@ begin
|
||||
halt(2);
|
||||
|
||||
if -(1+l)<>-1235 then
|
||||
halt(2);
|
||||
halt(3);
|
||||
|
||||
if -1-l<>-1235 then
|
||||
halt(4);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user