add fast-math-flags to 'call' instructions (PR21290)
authorSanjay Patel <spatel@rotateright.com>
Mon, 14 Dec 2015 21:59:03 +0000 (21:59 +0000)
committerSanjay Patel <spatel@rotateright.com>
Mon, 14 Dec 2015 21:59:03 +0000 (21:59 +0000)
commita3a48d96c997f098f504a250ccd38dcb773c233c
treef973d1ed2b87d2a2246810f2d7565ce3f45df481
parent49f241bc5a4725b7a2493a17bb92e7480c46a54e
add fast-math-flags to 'call' instructions (PR21290)

This patch adds optional fast-math-flags (the same that apply to fmul/fadd/fsub/fdiv/frem/fcmp)
to call instructions in IR. Follow-up patches would use these flags in LibCallSimplifier, add
support to clang, and extend FMF to the DAG for calls.

Motivating example:

%y = fmul fast float %x, %x
%z = tail call float @sqrtf(float %y)

We'd like to be able to optimize sqrt(x*x) into fabs(x). We do this today using a function-wide
attribute for unsafe-math, but we really want to trigger on the instructions themselves:

%z = tail call fast float @sqrtf(float %y)

because in an LTO build it's possible that calls with fast semantics have been inlined into a
function with non-fast semantics.

The code changes and tests are based on the recent commits that added "notail":
http://reviews.llvm.org/rL252368

and added FMF to fcmp:
http://reviews.llvm.org/rL241901

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255555 91177308-0d34-0410-b5e6-96231b3b80d8
14 files changed:
docs/LangRef.rst
include/llvm/Bitcode/LLVMBitCodes.h
include/llvm/IR/IRBuilder.h
lib/AsmParser/LLParser.cpp
lib/Bitcode/Reader/BitcodeReader.cpp
lib/Bitcode/Writer/BitcodeWriter.cpp
test/Bitcode/compatibility.ll
test/Transforms/InstCombine/fast-math.ll
test/Transforms/InstCombine/inline-intrinsic-assert.ll
test/Transforms/InstCombine/log-pow.ll
test/Transforms/InstCombine/no_cgscc_assert.ll
test/Transforms/InstCombine/pow-exp.ll
test/Transforms/InstCombine/pow-exp2.ll
unittests/IR/IRBuilderTest.cpp