[LLVMbugs] [Bug 10254] New: Phi with identical arguments not optimized

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jul 2 20:24:24 PDT 2011


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

           Summary: Phi with identical arguments not optimized
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: rafael.espindola at gmail.com
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=6818)
 --> (http://llvm.org/bugs/attachment.cgi?id=6818)
test.ll

I was curious why early tail dup in CodeGen was seeing trivial bb like

foo:
  jmp bar

since I would expect simplifycfg to handle them.

One case I found is attached. We have code that looks like:

----------------------------
bb0:                   ; preds = %for.body7.i
  %gep0 = getelementptr inbounds i8* %call.i.i.i.i, i64 8
  %cast0 = bitcast i8* %gep0 to %"class.llvm::MallocAllocator"**
  br label %bb2

bb1:                                ; preds = %for.body7.i
  %second.i.i.i.i.i = getelementptr inbounds i8* %call.i.i.i.i, i64 8
  %cast1 = bitcast i8* %second.i.i.i.i.i to %"class.llvm::MallocAllocator"**

  Use of cast1

  br label %bb2

bb2: ; preds = %bb1, %bb0
  %.pre-phi.i.i.i = phi %"class.llvm::MallocAllocator"** [ %cast0, %bb0 ], [
%cast1, %bb1 ]
----------------------------

codegenprepare will move gep0 and cast0, making bb0 empty, but that is too late
for simplifycfg. One way to optimize this early would be to move both the gep
and cast to for.body7.i and remove the phi. After that simplifycfg would remove
bb0.

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