[LLVMbugs] [Bug 16316] New: aggregate store isn't optimized properly

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jun 12 23:45:20 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16316

            Bug ID: 16316
           Summary: aggregate store isn't optimized properly
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: deadalnix at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Code below can't be optimized further by LLVM :

%A__vtbl = type { i8*, i32 (%A*)* }
%A = type { %A__vtbl* }

@A__vtblZ = constant %A__vtbl { i8* null, i32 (%A*)* @A.foo }
@A__initZ = constant %A { %A__vtbl* @A__vtblZ }

define i32 @_Dmain() {
body:
  %0 = tail call i8* @_d_allocmemory(i64 8)
  %1 = bitcast i8* %0 to %A*
  ; %optimized = bitcast i8* %0 to %A__vtbl**
  ; store %A__vtbl* @A__vtblZ, %A__vtbl** %optimized, align 8
  store %A { %A__vtbl* @A__vtblZ }, %A* %1, align 8
  %2 = getelementptr inbounds %A* %1, i32 0, i32 0
  %vtbl.i = load %A__vtbl** %2, align 8
  %3 = getelementptr inbounds %A__vtbl* %vtbl.i, i64 0, i32 1
  %4 = load i32 (%A*)** %3, align 8
  %5 = tail call i32 %4(%A* %1)
  ret i32 %5
}

define i32 @A.foo(%A* nocapture %this) nounwind readnone {
body:
  ret i32 42
}

declare i8* @_d_allocmemory(i64)

I the store is replaced by the commented code just above, the LLVM is able to
do its job and optimize the virtual call, inline and directly return 42.

-- 
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/20130613/c076701d/attachment.html>


More information about the llvm-bugs mailing list