<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - MemCpyOpt: uses sext instead of zext for memcpy/memset size subtraction"
   href="https://bugs.llvm.org/show_bug.cgi?id=47697">47697</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>MemCpyOpt: uses sext instead of zext for memcpy/memset size subtraction
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

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

        <tr>
          <th>Keywords</th>
          <td>miscompilation
          </td>
        </tr>

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

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

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nunoplopes@sapo.pt
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>ahmed@bougacha.org, benny.kra@gmail.com, florian_hahn@apple.com, juneyoung.lee@sf.snu.ac.kr, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Test: Transforms/MemCpyOpt/memset-memcpy-redundant-memset.ll

MemCpyOpt sign-extends the difference between memcpy/memset sizes instead of
zero-extending them.

<a href="https://alive2.llvm.org/ce/z/RgKeyt">https://alive2.llvm.org/ce/z/RgKeyt</a>

----------------------------------------
define void @src(* %dst, * %src, i8 %dst_size, i8 %src_size, i8 %c) {
  memset * %dst align 1, i8 %c, i8 %dst_size
  memcpy * %dst align 1, * %src align 1, i8 %src_size
  ret void
}
=>
define void @src(* %dst, * %src, i8 %dst_size, i8 %src_size, i8 %c) {
  %1 = usub_sat i8 %dst_size, %src_size
  %2 = sext i8 %src_size to i64
  %3 = gep * %dst, 1 x i64 %2
  memset * %3 align 1, i8 %c, i8 %1
  memcpy * %dst align 1, * %src align 1, i8 %src_size
  ret void
}
Transformation doesn't verify!
ERROR: Source is more defined than target

Example:
* %dst = pointer(non-local, block_id=1, offset=96)
* %src = pointer(non-local, block_id=1, offset=9007199254741152)
i8 %dst_size = #x83 (131, -125)
i8 %src_size = #x82 (130, -126)
i8 %c = any

Source:

SOURCE MEMORY STATE
===================
NON-LOCAL BLOCKS:
Block 0 >       size: 0 align: 1        alloc type: 0
Block 1 >       size: 2305843009213693952       align: 2        alloc type: 0
Block 2 >       align: 2        alloc type: 0

Target:
i8 %1 = #x01 (1)
i64 %2 = #xffffffffffffff82 (18446744073709551490, -126)
* %3 = pointer(non-local, block_id=1, offset=-30)


Summary:
  0 correct transformations
  1 incorrect transformations
  0 Alive2 errors

<a href="https://web.ist.utl.pt/nuno.lopes/alive2/index.php?hash=1546033e6d866cfc&test=Transforms%2FMemCpyOpt%2Fmemset-memcpy-redundant-memset.ll">https://web.ist.utl.pt/nuno.lopes/alive2/index.php?hash=1546033e6d866cfc&test=Transforms%2FMemCpyOpt%2Fmemset-memcpy-redundant-memset.ll</a></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>