[llvm-commits] [llvm] r162173 - in /llvm/trunk: lib/Transforms/Scalar/SimplifyLibCalls.cpp test/Transforms/SimplifyLibCalls/floor.ll
Benjamin Kramer
benny.kra at googlemail.com
Sat Aug 18 12:27:32 PDT 2012
Author: d0k
Date: Sat Aug 18 14:27:32 2012
New Revision: 162173
URL: http://llvm.org/viewvc/llvm-project?rev=162173&view=rev
Log:
SimplifyLibcalls: Add fabs and trunc to the list of libcalls that are safe to shrink from double to float.
Modified:
llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp
llvm/trunk/test/Transforms/SimplifyLibCalls/floor.ll
Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=162173&r1=162172&r2=162173&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Sat Aug 18 14:27:32 2012
@@ -1641,6 +1641,8 @@
Optimizations["llvm.exp2.f64"] = &Exp2;
Optimizations["llvm.exp2.f32"] = &Exp2;
+ if (TLI->has(LibFunc::fabs) && TLI->has(LibFunc::fabsf))
+ Optimizations["fabs"] = &UnaryDoubleFP;
if (TLI->has(LibFunc::floor) && TLI->has(LibFunc::floorf))
Optimizations["floor"] = &UnaryDoubleFP;
if (TLI->has(LibFunc::ceil) && TLI->has(LibFunc::ceilf))
@@ -1651,6 +1653,8 @@
Optimizations["rint"] = &UnaryDoubleFP;
if (TLI->has(LibFunc::nearbyint) && TLI->has(LibFunc::nearbyintf))
Optimizations["nearbyint"] = &UnaryDoubleFP;
+ if (TLI->has(LibFunc::trunc) && TLI->has(LibFunc::truncf))
+ Optimizations["trunc"] = &UnaryDoubleFP;
// Integer Optimizations
Optimizations["ffs"] = &FFS;
Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/floor.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/floor.ll?rev=162173&r1=162172&r2=162173&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyLibCalls/floor.ll (original)
+++ llvm/trunk/test/Transforms/SimplifyLibCalls/floor.ll Sat Aug 18 14:27:32 2012
@@ -9,6 +9,8 @@
; DO-SIMPLIFY: call float @ceilf(
; DO-SIMPLIFY: call float @roundf(
; DO-SIMPLIFY: call float @nearbyintf(
+; DO-SIMPLIFY: call float @truncf(
+; DO-SIMPLIFY: call float @fabsf(
; C89-SIMPLIFY: call float @floorf(
; C89-SIMPLIFY: call float @ceilf(
@@ -19,6 +21,8 @@
; DONT-SIMPLIFY: call double @ceil(
; DONT-SIMPLIFY: call double @round(
; DONT-SIMPLIFY: call double @nearbyint(
+; DONT-SIMPLIFY: call double @trunc(
+; DONT-SIMPLIFY: call double @fabs(
declare double @floor(double)
@@ -28,6 +32,10 @@
declare double @nearbyint(double)
+declare double @trunc(double)
+
+declare double @fabs(double)
+
define float @test_floor(float %C) {
%D = fpext float %C to double ; <double> [#uses=1]
; --> floorf
@@ -60,3 +68,18 @@
ret float %F
}
+define float @test_trunc(float %C) {
+ %D = fpext float %C to double
+ ; --> truncf
+ %E = call double @trunc(double %D)
+ %F = fptrunc double %E to float
+ ret float %F
+}
+
+define float @test_fabs(float %C) {
+ %D = fpext float %C to double
+ ; --> fabsf
+ %E = call double @fabs(double %D)
+ %F = fptrunc double %E to float
+ ret float %F
+}
More information about the llvm-commits
mailing list