summaryrefslogtreecommitdiff
path: root/test/Transforms/SimplifyLibCalls/floor.ll
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms/SimplifyLibCalls/floor.ll')
-rw-r--r--test/Transforms/SimplifyLibCalls/floor.ll39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/Transforms/SimplifyLibCalls/floor.ll b/test/Transforms/SimplifyLibCalls/floor.ll
new file mode 100644
index 0000000000000..31eb3f65623f5
--- /dev/null
+++ b/test/Transforms/SimplifyLibCalls/floor.ll
@@ -0,0 +1,39 @@
+; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis > %t
+; RUN: not grep {call.*floor(} %t
+; RUN: grep {call.*floorf(} %t
+; RUN: not grep {call.*ceil(} %t
+; RUN: grep {call.*ceilf(} %t
+; RUN: not grep {call.*nearbyint(} %t
+; RUN: grep {call.*nearbyintf(} %t
+; XFAIL: sparc
+
+declare double @floor(double)
+
+declare double @ceil(double)
+
+declare double @nearbyint(double)
+
+define float @test_floor(float %C) {
+ %D = fpext float %C to double ; <double> [#uses=1]
+ ; --> floorf
+ %E = call double @floor( double %D ) ; <double> [#uses=1]
+ %F = fptrunc double %E to float ; <float> [#uses=1]
+ ret float %F
+}
+
+define float @test_ceil(float %C) {
+ %D = fpext float %C to double ; <double> [#uses=1]
+ ; --> ceilf
+ %E = call double @ceil( double %D ) ; <double> [#uses=1]
+ %F = fptrunc double %E to float ; <float> [#uses=1]
+ ret float %F
+}
+
+define float @test_nearbyint(float %C) {
+ %D = fpext float %C to double ; <double> [#uses=1]
+ ; --> nearbyintf
+ %E = call double @nearbyint( double %D ) ; <double> [#uses=1]
+ %F = fptrunc double %E to float ; <float> [#uses=1]
+ ret float %F
+}
+