diff options
| author | Richard Osborne <richard@xmos.com> | 2011-03-03 14:09:28 +0000 |
|---|---|---|
| committer | Richard Osborne <richard@xmos.com> | 2011-03-03 14:09:28 +0000 |
| commit | 2dfb888392d4d82f467dfc8c9c4d2192cd71afb6 (patch) | |
| tree | 11d18960b78a1b1d43b6df4e50dd1dcb470ab241 /llvm/test/Transforms/SimplifyLibCalls | |
| parent | 969dfbcff62e8c86084a6d9ae1f05c0a03b347dc (diff) | |
| download | bcm5719-llvm-2dfb888392d4d82f467dfc8c9c4d2192cd71afb6.tar.gz bcm5719-llvm-2dfb888392d4d82f467dfc8c9c4d2192cd71afb6.zip | |
Optimize sprintf -> siprintf if there are no floating point arguments
and siprintf is available on the target.
llvm-svn: 126937
Diffstat (limited to 'llvm/test/Transforms/SimplifyLibCalls')
| -rw-r--r-- | llvm/test/Transforms/SimplifyLibCalls/iprintf.ll | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/test/Transforms/SimplifyLibCalls/iprintf.ll b/llvm/test/Transforms/SimplifyLibCalls/iprintf.ll index 11385cb75d4..b99de6efb87 100644 --- a/llvm/test/Transforms/SimplifyLibCalls/iprintf.ll +++ b/llvm/test/Transforms/SimplifyLibCalls/iprintf.ll @@ -26,4 +26,25 @@ entry: ret void } +; Verify sprintf with no floating point arguments is transformed to siprintf +define i32 @f2(i8* %p, i32 %x) nounwind { +entry: +; CHECK: define i32 @f2 +; CHECK: @siprintf +; CHECK: } + %0 = tail call i32 (i8*, i8*, ...)* @sprintf(i8 *%p, i8* getelementptr ([4 x i8]* @.str1, i32 0, i32 0), i32 %x) + ret i32 %0 +} + +; Verify we don't turn this into an siprintf call +define i32 @f3(i8* %p, double %x) nounwind { +entry: +; CHECK: define i32 @f3 +; CHECK: @sprintf +; CHECK: } + %0 = tail call i32 (i8*, i8*, ...)* @sprintf(i8 *%p, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), double %x) + ret i32 %0 +} + declare i32 @printf(i8* nocapture, ...) nounwind +declare i32 @sprintf(i8* nocapture, i8* nocapture, ...) nounwind |

