<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW " title="NEW --- - memcpy and memmove are lowered the same way" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24056&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=gGOiiokY4gWa7FYsoYJlk78ucAKKu5J34d3Rzgh_r-w&s=o9rtRJpw4PVeqKtLRw4tdsQqnR-1gnIqdJ-be1QSCVw&e=">24056</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>memcpy and memmove are lowered the same way
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: PTX
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>eliben@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In NVPTXLowerAggrCopies, NVPTX lowers llvm.memcpy and llvm.memmove in exactly
the same way, by producing load-store loops counting up. Here's a sample
lowering to PTX:

    ld.param.u64     %rd2, [_Z11foo_memmovePfS_j_param_0];
    ld.param.u64     %rd3, [_Z11foo_memmovePfS_j_param_1];
    ld.param.u32     %rd1, [_Z11foo_memmovePfS_j_param_2];
    mov.u64     %rd9, 0;
LBB1_1:
    add.s64     %rd7, %rd2, %rd9;
    ld.u8     %rs1, [%rd7];
    add.s64     %rd8, %rd3, %rd9;
    st.u8     [%rd8], %rs1;
    add.s64     %rd9, %rd9, 1;
    setp.lt.u64    %p1, %rd9, %rd1;
    @%p1 bra     LBB1_1;
    ret;

This is incorrect for memmove, which guarantees to work correctly when the
ranges of source and destination overlap. If source starts lower than dest and
there's an overlap, the result will be incorrect.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>