[fpc-devel] x86_64 Optimizer Overhaul
J. Gareth Moreton
gareth at moreton-family.com
Sun Dec 2 23:24:47 CET 2018
That's interesting. Thanks for that. Time to get fixing.
In the meantime I'm also fixing up the buggy optimisation that caused the
original crash on Linux... nothing against the contributor, but it looks
like some badly-copied code from the MovXX routine... it even still
mentions "movsx" in the comments!
Hopefully this effort on the overhaul won't all be for naught.
Gareth aka. Kit
On Sun 02/12/18 23:21 , "Marģers ." margers.roked at inbox.lv sent:
I run it no linux. Problem code part.
type PLongData = ^TLongData;
TLongData = array [0..100] of longint;
function binarySearchLong ( sortedArray:PLongData; nLen,
toFind:longint):longint;
var low, high, mid, l, h, m : longint;
begin
{ Returns index of toFind in sortedArray, or -1 if not found}
low := 0;
high := nLen - 1;
l := sortedArray^[low];
h := sortedArray^[high];
while ((l = toFind)) do
begin
mid := (low + high) shr 1; { var "low" in register
r8d }
m := sortedArray^[mid];
if (m < toFind) then
begin
low := mid + 1;
l := sortedArray^[low];
{ asm code generated
-- with trunk
lea r8d,
[r11d+1H]
mov esi, r8d
--end trunk
-- with overhaul it never set r8d to new value, but should
lea esi,
[r11d+1H]
-- end overhaul
mov r10d, dword
[rdi+rsi*4]
jmp
?_00144
}
end else
if (m > toFind) then
begin
high := mid - 1;
h := sortedArray^[high];
end else
begin
binarySearchLong:=mid;
exit;
end;
end;
if (sortedArray^[low] = toFind) then
begin
binarySearchLong:=low;
end else
binarySearchLong := -1; { Not found}
end;
----- Reply to message -----
Subject: Re: [fpc-devel] x86_64 Optimizer Overhaul
Date: 2018. gada 2. decembris 23:32:36
From: J. Gareth Moreton
To: FPC developers' list Thanks for the feedback. Do you have a
reproducible case, and does it fail on Linux or Windows? I'll have a look
for the infinite loops in the meantime. Gareth aka. Kit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20181202/77b9ac7e/attachment.html>
More information about the fpc-devel
mailing list