OSDN Git Service

Shrinkify libcalls: use float versions of double libm functions with fast-math (bug...
authorSanjay Patel <spatel@rotateright.com>
Wed, 22 Oct 2014 15:29:23 +0000 (15:29 +0000)
committerSanjay Patel <spatel@rotateright.com>
Wed, 22 Oct 2014 15:29:23 +0000 (15:29 +0000)
commitdc18ebc4b12d64ada969a5879cff162933b029ba
tree5a2d896bee4c5b8f11a6ddaac223c7db9acc363b
parentd5b89313e03fce6f91a1e925848e9023863c7d7e
Shrinkify libcalls: use float versions of double libm functions with fast-math (bug 17850)

When a call to a double-precision libm function has fast-math semantics
(via function attribute for now because there is no IR-level FMF on calls),
we can avoid fpext/fptrunc operations and use the float version of the call
if the input and output are both float.

We already do this optimization using a command-line option; this patch just
adds the ability for fast-math to use the existing functionality.

I moved the cl::opt from InstructionCombining into SimplifyLibCalls because
it's only ever used internally to that class.

Modified the existing test cases to use the unsafe-fp-math attribute rather
than repeating all tests.

This patch should solve: http://llvm.org/bugs/show_bug.cgi?id=17850

Differential Revision: http://reviews.llvm.org/D5893

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220390 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Transforms/Utils/SimplifyLibCalls.h
lib/Transforms/InstCombine/InstructionCombining.cpp
lib/Transforms/Utils/SimplifyLibCalls.cpp
test/Transforms/InstCombine/double-float-shrink-1.ll