llvm-6502/test/Transforms/TailCallElim/2010-06-26-MultipleReturnValues.ll
Duncan Sands d0d3ccc827 Handle the case of a tail recursion in which the tail call is followed
by a return that returns a constant, while elsewhere in the function
another return instruction returns a different constant.  This is a
special case of accumulator recursion, so just generalize the existing
logic a bit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108241 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-13 15:41:41 +00:00

21 lines
645 B
LLVM

; RUN: opt < %s -tailcallelim -S | FileCheck %s
; PR7328
; PR7506
define i32 @foo(i32 %x) {
; CHECK: define i32 @foo
; CHECK: %accumulator.tr = phi i32 [ 1, %entry ], [ 0, %body ]
entry:
%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]
; CHECK-NOT: call
ret i32 0
; CHECK: ret i32 %accumulator.tr
return: ; preds = %entry
ret i32 1
}