<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 23/01/2014 22:26, August Oktobar
      wrote:<br>
    </div>
    <blockquote
cite="mid:CABQ5zt2Pzr5yCp_7FNfBrYLc=T42o-9murcGQeUpHQgtx_O7SA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div id="gt-src-tools">
          <div id="gt-src-tools-l">
            <div style="display:inline-block" id="gt-input-tool">
              <div id="itamenu"><span class=""></span></div>
            </div>
          </div>
        </div>
        <div id="gt-res-content" class="">
          <div dir="ltr" style="zoom:1">
            <span id="result_box" class="" lang="en"><span class="">Hello,</span>
              <span class="">I have seen your</span> <span class="">mails</span>
              <span class="">about</span> <span class="">peephole</span>
              <span class="">optimization</span><span class="">,</span>
              <span class="">so I wonder</span> <span class="">if you
                could</span> <span class="">look at this</span> <span
                class="">reports</span><br class="">
              <span class=""><a moz-do-not-send="true"
                  href="http://bugs.freepascal.org/view.php?id=23595">http://bugs.freepascal.org/view.php?id=23595</a></span>
              <br class="">
              <br class="">
              <span class="">or</span> <span class="">perhaps</span> <span
                class="">optimize</span> <span class="">slow</span> </span><span
              id="result_box" class="" lang="en"><span class="">array</span>
              <span class=""></span></span><span id="result_box"
              class="" lang="en"><span class="">access </span><span
                class="">using</span> <span class="">operator</span> <span
                class="">[]</span> (it is faster to use pointer
              arithmetics)<br>
              <br>
            </span></div>
          <div style=""><span id="result_box" class="" lang="en">thanks!<br>
            </span></div>
        </div>
      </div>
    </blockquote>
    <br>
    1) I am just getting started on this, so I can only answer with
    limited knowledge.<br>
        @experts, please correct me below, where needed<br>
    2) The peephole opt is only something I do "on the side" as it
    currently is.<br>
    <br>
    From a quick glance, this does not look like something for the
    peephole opt. <br>
    <br>
    The peephole opt currently looks at statements that are close
    together (follow each other immediately). <br>
    I am not sure to which extend (if at all) it would be acceptable to
    break that limit (it is doable, question is if desired).<br>
    <br>
    In this specific case:<br>
    1) between the "fstpl" and the "mov (half_the_data), %edi" are other
    statements.<br>
      detecting the connection would either:<br>
      - need scanning several statements ahead. This would be slow,
    because it had to be done after each storing "something to memory"
    (so very often)<br>
      - keeping state of all the involved registers and memory (do-able
    / interesting at least from a theoretical view / but not sure if
    desired)<br>
    2) only half the mem is accessed, and then the other half. That
    means to detect the connection between the mem read and the
    register, it is needed to analyse 4 statements. Very unlikely to see
    this in the peephole opt.<br>
    <br>
    The livelihood of "a[i]" needs to be checked where the code is
    generated.<br>
    <br>
  </body>
</html>