[LLVMbugs] [Bug 7506] New: Case in which TailRecursionElimination could do better

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jun 26 05:58:55 PDT 2010


           Summary: Case in which TailRecursionElimination could do better
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: baldrick at free.fr
                CC: llvmbugs at cs.uiuc.edu

The tail recursion in the following testcase could be eliminated by introducing
a phi node for the return value (1, if coming from the entry block, 0 if coming
from the tail recursion jump), i.e. much the same as the existing accumulator
recursion logic, only simpler.

define i32 @foo(i32 %x) {
  %cond = icmp ugt i32 %x, 0                      ; <i1> [#uses=1]
  br i1 %cond, label %return, label %body

body:                                             ; preds = %entry
  %y = add i32 %x, 1                              ; <i32> [#uses=1]
  %tmp = call i32 @foo(i32 %y)                    ; <i32> [#uses=0]
  ret i32 0

return:                                           ; preds = %entry
  ret i32 1

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