[LLVMbugs] [Bug 1879] New: Branch folding deficiency

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon Dec 24 13:01:25 PST 2007


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

           Summary: Branch folding deficiency
           Product: libraries
           Version: 1.0
          Platform: PC
        OS/Version: All
            Status: NEW
          Keywords: code-quality
          Severity: minor
          Priority: P2
         Component: Common Code Generator Code
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sabre at nondot.org
                CC: llvmbugs at cs.uiuc.edu


Ptrdist/ks contains this amusing code in its inner loop:

        movss   _cost(,%edx,4), %xmm1
LBB2_3: # bb
        je      LBB2_7  # bb41
LBB2_4: # bb32
        movaps  %xmm1, %xmm2
        addss   %xmm0, %xmm2
        cmpl    %ecx, 4(%esi)
        je      LBB2_6  # bb32
LBB2_5: # bb32
        movaps  %xmm0, %xmm2
LBB2_6: # bb32
        movaps  %xmm2, %xmm0
        movl    (%esi), %esi
        testl   %esi, %esi
        jmp     LBB2_3  # bb


The inner lop is BB3/4/5/6.  Note that BB6 contains an uncond branch *just* to
a cond branch.  It seems branch folding should duplicate the conditional branch
into the end of BB6.

The bigger issue with this code is that it contains a conditional add.  It is
turning:

    if ((*modNode).module == module)
        gain = gain + netCost;

Into a select:  cond ? (gain+netCost) : gain;

And then the select is turned into a conditional branch, and the add isn't sunk
into the conditional block.


To see this, plop this into the top of KS-2.c
float CAiBj(ModuleRecPtr mrA, ModuleRecPtr mrB) __attribute__((noinline));

-Chris


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