* transform -x-1 into not(x), resolves #40313

This commit is contained in:
florian 2024-03-05 22:10:56 +01:00
parent 1f2203c304
commit 59c77a48b5
2 changed files with 16 additions and 0 deletions

View File

@ -932,6 +932,13 @@ implementation
left:=nil;
tmoddivnode(right).right:=nil;
exit;
end
{ transform -x-1 into not(x) }
else if is_signed(ld) and is_constintnode(right) and (tordconstnode(right).value=1) and (left.nodetype=unaryminusn) then
begin
result:=cnotnode.create(tunaryminusnode(left).left.getcopy);
exit;
end;
end;

9
tests/tbs/tb0711.pp Normal file
View File

@ -0,0 +1,9 @@
var
l : longint;
begin
l:=1234;
if -l-1<>-1235 then
halt(1);
end.