[LLVMbugs] [Bug 11412] New: missed reassociate due to GEP

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Nov 20 21:52:35 PST 2011


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

             Bug #: 11412
           Summary: missed reassociate due to GEP
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: nicholas at mxc.ca
                CC: llvmbugs at cs.uiuc.edu, richard-llvm at metafoo.co.uk
    Classification: Unclassified


This is a copy of part of std::vector's _M_insert_aux, the function that causes
v.push_back(4) to not get inlined.

  define i8* @test(i8* %ptr, i8* %ptr2) {
    %A = getelementptr inbounds i8* %ptr, i64 -1

    %B = ptrtoint i8* %A to i64
    %C = ptrtoint i8* %ptr2 to i64
    %D1 = sub i64 %C, %B
    %F = getelementptr inbounds i8* %ptr, i64 %D1

    ret i8* %F
  }

If we prevent instcombine from forming overflow intrinsics (no PR# but those
block us from getting this far), we get the above sequence. Stop me if I'm
wrong but that's:

  %F = ptr + ( (ptr2) - (ptr - 1) )
     = ptr + ptr2 - ptr + 1
     = ptr2 + 1
     = getelementptr inbounds i8* %ptr2, i64 1

Probably instcombine should go get that, maybe reassociate.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list