<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 - [Inliner] Noalias metadata incorrectly added to simplified calls"
   href="https://bugs.llvm.org/show_bug.cgi?id=50589">50589</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[Inliner] Noalias metadata incorrectly added to simplified calls
          </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>enhancement
          </td>
        </tr>

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

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

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

        <tr>
          <th>Reporter</th>
          <td>nikita.ppv@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jeroen.dobbelaere@synopsys.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>From <a href="https://reviews.llvm.org/D102110#inline-972360">https://reviews.llvm.org/D102110#inline-972360</a>:

define <2 x i8> @callee(<2 x i8>* %ptr1, <2 x i8>* noalias %ptr2, <2 x i1>
%mask, <2 x i8> %passthru) {
  %ret = call <2 x i8> @llvm.masked.load.v2i8(<2 x i8>* %ptr1, i32 1, <2 x i1>
%mask, <2 x i8> %passthru)
  store <2 x i8> zeroinitializer, <2 x i8>* %ptr2
  ret <2 x i8> %ret
}

define void @caller(<2 x i8>* %ptr1, <2 x i8>* %ptr2) {
  %passthru = load <2 x i8>, <2 x i8>* %ptr2
  call <2 x i8> @callee(<2 x i8>* %ptr1, <2 x i8>* %ptr2, <2 x i1>
zeroinitializer, <2 x i8> %passthru)
  ret void
}

declare <2 x i8> @llvm.masked.load.v2i8(<2 x i8>*, i32, <2 x i1>, <2 x i8>)

Results in:

define <2 x i8> @callee(<2 x i8>* %ptr1, <2 x i8>* noalias %ptr2, <2 x i1>
%mask, <2 x i8> %passthru) {
  %ret = call <2 x i8> @llvm.masked.load.v2i8.p0v2i8(<2 x i8>* %ptr1, i32 1, <2
x i1> %mask, <2 x i8> %passthru)
  store <2 x i8> zeroinitializer, <2 x i8>* %ptr2, align 2
  ret <2 x i8> %ret
}

define void @caller(<2 x i8>* %ptr1, <2 x i8>* %ptr2) {
  %passthru = load <2 x i8>, <2 x i8>* %ptr2, align 2, !noalias !0
  call void @llvm.experimental.noalias.scope.decl(metadata !0)
  store <2 x i8> zeroinitializer, <2 x i8>* %ptr2, align 2, !alias.scope !0
  ret void
}

In this case, we don't even need the incorrect annotation to go on an
instruction from the caller, it can also happen with a callee instruction:

define <2 x i8> @callee(<2 x i8>* %ptr1, <2 x i8>* noalias %ptr2, <2 x i1>
%mask) {
  %passthru = load <2 x i8>, <2 x i8>* %ptr2
  %ret = call <2 x i8> @llvm.masked.load.v2i8(<2 x i8>* %ptr1, i32 1, <2 x i1>
%mask, <2 x i8> %passthru)
  store <2 x i8> zeroinitializer, <2 x i8>* %ptr2
  ret <2 x i8> %ret
}

define void @caller(<2 x i8>* %ptr1, <2 x i8>* %ptr2) {
  call <2 x i8> @callee(<2 x i8>* %ptr1, <2 x i8>* %ptr2, <2 x i1>
zeroinitializer)
  ret void
}

declare <2 x i8> @llvm.masked.load.v2i8(<2 x i8>*, i32, <2 x i1>, <2 x i8>)

Results in:

define <2 x i8> @callee(<2 x i8>* %ptr1, <2 x i8>* noalias %ptr2, <2 x i1>
%mask) {
  %passthru = load <2 x i8>, <2 x i8>* %ptr2, align 2
  %ret = call <2 x i8> @llvm.masked.load.v2i8.p0v2i8(<2 x i8>* %ptr1, i32 1, <2
x i1> %mask, <2 x i8> %passthru)
  store <2 x i8> zeroinitializer, <2 x i8>* %ptr2, align 2
  ret <2 x i8> %ret
}

define void @caller(<2 x i8>* %ptr1, <2 x i8>* %ptr2) {
  call void @llvm.experimental.noalias.scope.decl(metadata !0)
  %passthru.i = load <2 x i8>, <2 x i8>* %ptr2, align 2, !alias.scope !0,
!noalias !0
  store <2 x i8> zeroinitializer, <2 x i8>* %ptr2, align 2, !alias.scope !0
  ret void
}

Note how the metadata is claiming that the load does not alias ... with itself.

We should not be adding noalias metadata to instructions that are the result of
simplification, as they may not correspond to the instruction from the original
function.</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>