[LLVMbugs] [Bug 12013] New: Missing optimization (cmp GEP(alloca) with null)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Feb 15 21:42:55 PST 2012


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

             Bug #: 12013
           Summary: Missing optimization (cmp GEP(alloca) with null)
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: pete.cooper at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 8063
  --> http://llvm.org/bugs/attachment.cgi?id=8063
IR for a smallvector push_back

The attached test case is the IR from this C++ on revision 150655.

#include "llvm/ADT/SmallVector.h"

using namespace llvm;
void g(SmallVector<int, 8>&);

void test()
{
  SmallVector<int, 8> sv;
  sv.push_back(1);
  g(sv);
}

This is a very common pattern in the compiler but fails to optimize this
sequence

%sv = alloca %"class.llvm::SmallVector", align 16
%2 = getelementptr inbounds %"class.llvm::SmallVector"* %sv, i64 0, i32 0, i32
0, i32 0, i32 0, i32 3
%8 = icmp eq %"union.llvm::SmallVectorBase::U"* %2, null
br i1 %8, label %_ZN4llvm15SmallVectorImplIiE9push_backERKi.exit, label %9

Adding an optimization to SimplifyICmpInst make this become br i1 false, but
the branch isn't actually removed.  I haven't yet looked into how we can make
sure this triggers branch removal.

-- 
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