<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 - Alignment assumptions prevent SROA"
   href="https://bugs.llvm.org/show_bug.cgi?id=45763">45763</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Alignment assumptions prevent SROA
          </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>Scalar 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>llvm-bugs@lists.llvm.org, Matthew.Arsenault@amd.com, stanislav.mekhanoshin@amd.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>As reported in <a href="https://reviews.llvm.org/D76886#2008588">https://reviews.llvm.org/D76886#2008588</a>:

; RUN: opt -S -O3 -preserve-alignment-assumptions-during-inlining=true < %s |
FileCheck %s

; CHECK: @caller
; CHECK-NOT: alloca
; CHECK-NEXT: ret void

target datalayout = "e-p:64:64-p5:32:32-A5"

define amdgpu_kernel void @caller() {
  %alloca = alloca i64, align 8, addrspace(5)
  %cast = addrspacecast i64 addrspace(5)* %alloca to i64*
  call void @callee(i64* sret align 8 %cast)
  ret void
}

define internal void @callee(i64* noalias sret align 8 %arg) {
  store i64 0, i64* %arg, align 8
  ret void
}

This results in:

target datalayout = "e-p:64:64-p5:32:32-A5"

define amdgpu_kernel void @caller() local_unnamed_addr {
  %alloca = alloca i64, align 8, addrspace(5)
  %cast = addrspacecast i64 addrspace(5)* %alloca to i64*
  %ptrint = ptrtoint i64* %cast to i64
  %maskedptr = and i64 %ptrint, 7
  %maskcond = icmp eq i64 %maskedptr, 0
  call void @llvm.assume(i1 %maskcond)
  ret void
}

declare void @llvm.assume(i1)

The ptrtoint this introduces prevents SROA.

Likely the solution to this is not a change to SROA, but a change to the
representation of alignment assumptions (via assume bundles).</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>