diff options
author | Sanjay Patel <spatel@rotateright.com> | 2015-12-14 21:59:03 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2015-12-14 21:59:03 +0000 |
commit | fa54acedd1fd1183143c0a7f4b77554fd8cdb1ec (patch) | |
tree | 6e7cbff67fd8ec8795d8a0cb7a4e3f1d00a92302 /llvm/test/Bitcode/compatibility.ll | |
parent | 46642ffeebde1743980735e96303140f5f1a7b8b (diff) | |
download | bcm5719-llvm-fa54acedd1fd1183143c0a7f4b77554fd8cdb1ec.tar.gz bcm5719-llvm-fa54acedd1fd1183143c0a7f4b77554fd8cdb1ec.zip |
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
llvm-svn: 255555
Diffstat (limited to 'llvm/test/Bitcode/compatibility.ll')
-rw-r--r-- | llvm/test/Bitcode/compatibility.ll | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/test/Bitcode/compatibility.ll b/llvm/test/Bitcode/compatibility.ll index de0fc137e53..465facc2a88 100644 --- a/llvm/test/Bitcode/compatibility.ll +++ b/llvm/test/Bitcode/compatibility.ll @@ -664,6 +664,28 @@ define void @fastmathflags(float %op1, float %op2) { ret void } +; Check various fast math flags and floating-point types on calls. + +declare float @fmf1() +declare double @fmf2() +declare <4 x double> @fmf3() + +; CHECK-LABEL: fastMathFlagsForCalls( +define void @fastMathFlagsForCalls(float %f, double %d1, <4 x double> %d2) { + %call.fast = call fast float @fmf1() + ; CHECK: %call.fast = call fast float @fmf1() + + ; Throw in some other attributes to make sure those stay in the right places. + + %call.nsz.arcp = notail call nsz arcp double @fmf2() + ; CHECK: %call.nsz.arcp = notail call nsz arcp double @fmf2() + + %call.nnan.ninf = tail call nnan ninf fastcc <4 x double> @fmf3() + ; CHECK: %call.nnan.ninf = tail call nnan ninf fastcc <4 x double> @fmf3() + + ret void +} + ;; Type System %opaquety = type opaque define void @typesystem() { |