[llvm-bugs] [Bug 45763] New: Alignment assumptions prevent SROA

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 30 13:40:01 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45763

            Bug ID: 45763
           Summary: Alignment assumptions prevent SROA
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: nikita.ppv at gmail.com
                CC: llvm-bugs at lists.llvm.org, Matthew.Arsenault at amd.com,
                    stanislav.mekhanoshin at amd.com

As reported in https://reviews.llvm.org/D76886#2008588:

; 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).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200430/e6ce63df/attachment.html>


More information about the llvm-bugs mailing list