summaryrefslogtreecommitdiff
path: root/test/Transforms/SimplifyLibCalls
diff options
context:
space:
mode:
authorRichard Osborne <richard@xmos.com>2011-03-03 14:09:28 +0000
committerRichard Osborne <richard@xmos.com>2011-03-03 14:09:28 +0000
commit419454ad3720b8cf4613d9e790669c8beaccd1a4 (patch)
tree4a708cde9e05335c87db1a4b789f94010d66a077 /test/Transforms/SimplifyLibCalls
parent12785e87e88309c1934add000b754eba51a6c391 (diff)
downloadllvm-419454ad3720b8cf4613d9e790669c8beaccd1a4.tar.gz
llvm-419454ad3720b8cf4613d9e790669c8beaccd1a4.tar.bz2
llvm-419454ad3720b8cf4613d9e790669c8beaccd1a4.tar.xz
Optimize sprintf -> siprintf if there are no floating point arguments
and siprintf is available on the target. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126937 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/SimplifyLibCalls')
-rw-r--r--test/Transforms/SimplifyLibCalls/iprintf.ll21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/Transforms/SimplifyLibCalls/iprintf.ll b/test/Transforms/SimplifyLibCalls/iprintf.ll
index 11385cb75d..b99de6efb8 100644
--- a/test/Transforms/SimplifyLibCalls/iprintf.ll
+++ b/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