[LLVMbugs] [Bug 6992] New: Unfortunate code placement for PHI lowering

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Apr 30 09:46:18 PDT 2010


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

           Summary: Unfortunate code placement for PHI lowering
           Product: libraries
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: gohman at apple.com
                CC: llvmbugs at cs.uiuc.edu


In the testcase from PR2066:

define i32 @power(i32 %X) nounwind  {
entry:
        %cmp3 = icmp eq i32 %X, 0
        br i1 %cmp3, label %ifthen, label %ifend

ifthen:         ; preds = %ifend, %entry
        %accumulator.tr.lcssa = phi i32 [ 1, %entry ], [ %mul, %ifend ]
        ret i32 %accumulator.tr.lcssa

ifend:          ; preds = %ifend, %entry
        %indvar = phi i32 [ %indvar.next, %ifend ], [ 0, %entry ]
        %accumulator.tr1 = phi i32 [ %mul, %ifend ], [ 1, %entry ]
        %X.tr2 = sub i32 %X, %indvar
        %mul = mul i32 %X.tr2, %accumulator.tr1
        %indvar.next = add i32 %indvar, 1
        %exitcond = icmp eq i32 %indvar.next, %X
        br i1 %exitcond, label %ifthen, label %ifend
}

llc gets the loop right, but the rest of the function is hairy:

_power:                                 ## @power
## BB#0:                                ## %entry
        testl   %edi, %edi
        je      LBB0_3
## BB#1:                                ## %entry.ifend_crit_edge
        movl    $1, %eax
        .align  4, 0x90
LBB0_2:                                 ## %ifend
                                        ## =>This Inner Loop Header: Depth=1
        imull   %edi, %eax
        decl    %edi
        jne     LBB0_2
        jmp     LBB0_4
LBB0_3:                                 ## %entry.ifthen_crit_edge
        movl    $1, %eax
LBB0_4:                                 ## %ifthen
        ret

This code doesn't really need two "movl $1, %eax" instructions; just one in
BB#0 would suffice. Also, that would allow the loop exit to just fall through
into the return block rather than jumping over the extra movl.

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