From 892c923c469bf333909827ae5ae5f0ecd1b4b88f Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Wed, 3 Dec 2014 21:46:29 +0000 Subject: [PATCH] [SimplifyLibCalls] Enable double to float shrinking for copysign rdar://19049359 Differential Revision: http://reviews.llvm.org/D6495 llvm-svn: 223269 --- llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | 1 + llvm/test/Transforms/InstCombine/float-shrink-compare.ll | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index a39f128..6afde9e 100644 --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -2177,6 +2177,7 @@ Value *LibCallSimplifier::optimizeCall(CallInst *CI) { if (UnsafeFPShrink && hasFloatVersion(FuncName)) return optimizeUnaryDoubleFP(CI, Builder, true); return nullptr; + case LibFunc::copysign: case LibFunc::fmin: case LibFunc::fmax: if (hasFloatVersion(FuncName)) diff --git a/llvm/test/Transforms/InstCombine/float-shrink-compare.ll b/llvm/test/Transforms/InstCombine/float-shrink-compare.ll index e500467..ef1221b 100644 --- a/llvm/test/Transforms/InstCombine/float-shrink-compare.ll +++ b/llvm/test/Transforms/InstCombine/float-shrink-compare.ll @@ -222,8 +222,22 @@ define i32 @test18(float %x, float %y, float %z) nounwind uwtable { ; CHECK-NEXT: fcmp oeq float %fmaxf, %z } +define i32 @test19(float %x, float %y, float %z) nounwind uwtable { + %1 = fpext float %x to double + %2 = fpext float %y to double + %3 = call double @copysign(double %1, double %2) nounwind + %4 = fpext float %z to double + %5 = fcmp oeq double %3, %4 + %6 = zext i1 %5 to i32 + ret i32 %6 +; CHECK-LABEL: @test19( +; CHECK-NEXT: %copysignf = call float @copysignf(float %x, float %y) +; CHECK-NEXT: fcmp oeq float %copysignf, %z +} + declare double @fabs(double) nounwind readnone declare double @ceil(double) nounwind readnone +declare double @copysign(double, double) nounwind readnone declare double @floor(double) nounwind readnone declare double @nearbyint(double) nounwind readnone declare double @rint(double) nounwind readnone -- 2.7.4