diff options
author | dim <dim@FreeBSD.org> | 2012-04-14 13:54:10 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-04-14 13:54:10 +0000 |
commit | 1fc08f5e9ef733ef1ce6f363fecedc2260e78974 (patch) | |
tree | 19c69a04768629f2d440944b71cbe90adae0b615 /test/Transforms/Inline/noinline-recursive-fn.ll | |
parent | 07637c87f826cdf411f0673595e9bc92ebd793f2 (diff) | |
download | FreeBSD-src-1fc08f5e9ef733ef1ce6f363fecedc2260e78974.zip FreeBSD-src-1fc08f5e9ef733ef1ce6f363fecedc2260e78974.tar.gz |
Vendor import of llvm trunk r154661:
http://llvm.org/svn/llvm-project/llvm/trunk@r154661
Diffstat (limited to 'test/Transforms/Inline/noinline-recursive-fn.ll')
-rw-r--r-- | test/Transforms/Inline/noinline-recursive-fn.ll | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/test/Transforms/Inline/noinline-recursive-fn.ll b/test/Transforms/Inline/noinline-recursive-fn.ll index 1d5ebbb..6cde0e2 100644 --- a/test/Transforms/Inline/noinline-recursive-fn.ll +++ b/test/Transforms/Inline/noinline-recursive-fn.ll @@ -17,7 +17,7 @@ entry: bb: ; preds = %entry %1 = sub nsw i32 %x, 1 ; <i32> [#uses=1] call void @foo(i32 %1) nounwind ssp - volatile store i32 1, i32* @g, align 4 + store volatile i32 1, i32* @g, align 4 ret void return: ; preds = %entry @@ -42,7 +42,7 @@ entry: %0 = bitcast i8* %Bar to void (i32, i8*, i8*)* %1 = sub nsw i32 %x, 1 call void %0(i32 %1, i8* %Foo, i8* %Bar) nounwind - volatile store i32 42, i32* @g, align 4 + store volatile i32 42, i32* @g, align 4 ret void } @@ -54,7 +54,7 @@ entry: bb: ; preds = %entry %1 = bitcast i8* %Foo to void (i32, i8*, i8*)* ; <void (i32, i8*, i8*)*> [#uses=1] call void %1(i32 %x, i8* %Foo, i8* %Bar) nounwind - volatile store i32 13, i32* @g, align 4 + store volatile i32 13, i32* @g, align 4 ret void return: ; preds = %entry @@ -71,3 +71,40 @@ entry: call void @f2(i32 123, i8* bitcast (void (i32, i8*, i8*)* @f1 to i8*), i8* bitcast (void (i32, i8*, i8*)* @f2 to i8*)) nounwind ssp ret void } + + +; Check that a recursive function, when called with a constant that makes the +; recursive path dead code can actually be inlined. +define i32 @fib(i32 %i) { +entry: + %is.zero = icmp eq i32 %i, 0 + br i1 %is.zero, label %zero.then, label %zero.else + +zero.then: + ret i32 0 + +zero.else: + %is.one = icmp eq i32 %i, 1 + br i1 %is.one, label %one.then, label %one.else + +one.then: + ret i32 1 + +one.else: + %i1 = sub i32 %i, 1 + %f1 = call i32 @fib(i32 %i1) + %i2 = sub i32 %i, 2 + %f2 = call i32 @fib(i32 %i2) + %f = add i32 %f1, %f2 + ret i32 %f +} + +define i32 @fib_caller() { +; CHECK: @fib_caller +; CHECK-NOT: call +; CHECK: ret + %f1 = call i32 @fib(i32 0) + %f2 = call i32 @fib(i32 1) + %result = add i32 %f1, %f2 + ret i32 %result +} |