<HTML>
I believed I've fixed the bug. Thanks for your help.<br>
<br>
I had misunderstood one of the internal methods and, as a result, it wasn't resetting the register allocation usage with each iteration of the loop (and to add insult to injury, caused a memory leak!). By sheer coincidence, this wasn't a problem under Windows because of some additional code that skipped over the function prologue, but got triggered under Linux.<br>
<br>
I've updated all of the patch files in the bug report and added an additional one, since one function in particular got a bigger rework than everything else (overhaul-mov-refactor).<br>
<br>
I haven't had a chance to re-test the timings yet, although I've tried to provide a couple of additional savings for -O1 and -O2.<br>
<br>
<div>Gareth aka. Kit<br>
<br>
P.S. Note that the code is very messy with functions being split between i386 and x86_64. This is for testing and control cases. If x86_64 is successful, I intend to remove the distinctions and have i386 and x86_64 share the same overhaul. One platform at a time though!<br>
</div><div><br>
</div> <br>
<br>
<span style="font-weight: bold;">On Sun 02/12/18 23:21 , "Marģers ." margers.roked@inbox.lv sent:<br>
</span><blockquote style="BORDER-LEFT: #F5F5F5 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT:0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px"><div id="eml-cke__body" title="">I run it no linux. Problem code part.<br>
<br>
type PLongData = ^TLongData;<br>
TLongData = array [0..100] of longint;<br>
<br>
function binarySearchLong ( sortedArray:PLongData; nLen, toFind:longint):longint;<br>
var low, high, mid, l, h, m : longint;<br>
begin<br>
{ Returns index of toFind in sortedArray, or -1 if not found}<br>
low := 0;<br>
high := nLen - 1;<br>
<br>
l := sortedArray^[low];<br>
h := sortedArray^[high];<br>
<br>
while ((l <= toFind) and (h >= toFind)) do<br>
begin<br>
mid := (low + high) shr 1; { var "low" in register r8d }<br>
m := sortedArray^[mid];<br>
<br>
if (m < toFind) then<br>
begin<br>
low := mid + 1;<br>
l := sortedArray^[low];<br>
<br>
{ asm code generated<br>
-- with trunk<br>
lea r8d, [r11d+1H] <br>
mov esi, r8d<br>
--end trunk<br>
-- with overhaul it never set r8d to new value, but should<br>
lea esi, [r11d+1H] <br>
-- end overhaul<br>
<br>
mov r10d, dword [rdi+rsi*4] <br>
jmp ?_00144 <br>
<br>
}<br>
end else<br>
if (m > toFind) then<br>
begin<br>
high := mid - 1;<br>
h := sortedArray^[high];<br>
end else<br>
begin<br>
binarySearchLong:=mid;<br>
exit;<br>
end;<br>
<br>
end;<br>
<br>
if (sortedArray^[low] = toFind) then<br>
begin<br>
binarySearchLong:=low;<br>
end else<br>
binarySearchLong := -1; { Not found}<br>
end;<br>
<br>
</div>
<div id="eml-cke__signature_top" title="Paraksts">
<div class="eml-cke__signature" id="eml-cke__signature_top-wrap" title=""> </div>
</div>
<div class="noTransl">----- Reply to message -----<br>
<span style="font-weight: bold;">Subject: </span>Re: [fpc-devel] x86_64 Optimizer Overhaul<br>
<span style="font-weight: bold;">Date: </span>2018. gada 2. decembris 23:32:36<br>
<span style="font-weight: bold;">From: </span> J. Gareth Moreton <a href="javascript:top.opencompose('gareth@moreton-family.com','','','')"><gareth@moreton-family.com></gareth@moreton-family.com></a><br>
<span style="font-weight: bold;">To: </span> FPC developers' list <a href="javascript:top.opencompose('fpc-devel@lists.freepascal.org','','','')"><fpc-devel@lists.freepascal.org></fpc-devel@lists.freepascal.org></a></div>
<blockquote>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.
<div> </div>
<div>Gareth aka. Kit</div>
<blockquote>
<div> </div>
</blockquote>
</blockquote>
<div id="eml-cke__signature_bottom" title="Paraksts"> </div>
</blockquote></HTML>