[PATCH] D14707: add fast-math-flags to 'call' instructions (PR21290)

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 16 08:27:28 PST 2015


spatel created this revision.
spatel added reviewers: jmolloy, ahatanak, hfinkel.
spatel added a subscriber: llvm-commits.

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.

A motivating example is something like this:
  %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)

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

http://reviews.llvm.org/D14707

Files:
  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/no_cgscc_assert.ll
  test/Transforms/InstCombine/pow-exp.ll
  test/Transforms/InstCombine/pow-exp2.ll
  unittests/IR/IRBuilderTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14707.40288.patch
Type: text/x-patch
Size: 16405 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151116/2ce876ea/attachment.bin>


More information about the llvm-commits mailing list