Improve tail call elimination to handle the switch statement.
[oota-llvm.git] / test / Transforms / TailCallElim / accum_recursion_constant_arg.ll
1 ; This is a more aggressive form of accumulator recursion insertion, which 
2 ; requires noticing that X doesn't change as we perform the tailcall.  Thanks
3 ; go out to the anonymous users of the demo script for "suggesting" 
4 ; optimizations that should be done.  :)
5
6 ; RUN: opt < %s -tailcallelim -S | not grep call
7
8 define i32 @mul(i32 %x, i32 %y) {
9 entry:
10         %tmp.1 = icmp eq i32 %y, 0              ; <i1> [#uses=1]
11         br i1 %tmp.1, label %return, label %endif
12 endif:          ; preds = %entry
13         %tmp.8 = add i32 %y, -1         ; <i32> [#uses=1]
14         %tmp.5 = call i32 @mul( i32 %x, i32 %tmp.8 )            ; <i32> [#uses=1]
15         %tmp.9 = add i32 %tmp.5, %x             ; <i32> [#uses=1]
16         ret i32 %tmp.9
17 return:         ; preds = %entry
18         ret i32 %x
19 }
20