mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
SimplifyLibcalls: Add fabs and trunc to the list of libcalls that are safe to shrink from double to float.
llvm-svn: 162173
This commit is contained in:
parent
d01a7b5942
commit
31074f526a
@ -1641,6 +1641,8 @@ void SimplifyLibCalls::InitOptimizations() {
|
||||
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 @@ void SimplifyLibCalls::InitOptimizations() {
|
||||
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;
|
||||
|
@ -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 @round(double)
|
||||
|
||||
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 @@ define float @test_nearbyint(float %C) {
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user