[PATCH] D18513: Simplify isfinite/isnan/isinf in finite-math-only mode

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 30 13:50:22 PDT 2016


So, here are my thoughts on this. I'm curious what you, Steven, and others
think though....

My initial feeling is that -ffinite-math-only should apply to *math* and
not to *tests*. That is, we should be free to transform and optimize math
assuming finite operands, but we can't make any assumptions about the
results of testing for finite values. This means that the implementaiton of
complex gets to leverage finite-math-only, but we can't nuke tests for
infinities. I also think that we should aggressively optimize how the tests
are done while preserving their functionality. So I guess I'm suggesting
#2, #3, and #4 from your email as the path forward.

However, I can see an argument that forcing users to leverage
__FINITE_MATH_ONLY__ in their library code is really annoying. So I would
also be happy having two different mechanisms for testing for infinities
(and NaNs, I'm just using the inf case an my example) -- one which is
folded under finite-math-only, and one which survives. I'm not sure what to
call the two interfaces though. Ideas?

In either case, I think we should definitely replace calls to functions
with fast, inline, and ensured correct (according to whatever rules are
appropriate in the particular case) implementations of these tests.

Also in either case, I think we should change the frontend and/or headers
to add *call* attributes (on the actual call instruction) marking these
operations as finite-math-only rather than relying on *caller* attributes
or having to chase operands through phi nodes. This should essentially
follow the same model we use for tagging floating point operations that can
be optimized.

-Chandler

On Mon, Mar 28, 2016 at 3:23 AM Hal Finkel via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> hfinkel updated this revision to Diff 51774.
> hfinkel added a comment.
>
> Updated library function names for Darwin (and NetBSD).
>
>
> http://reviews.llvm.org/D18513
>
> Files:
>   include/llvm/Analysis/TargetLibraryInfo.def
>   include/llvm/Analysis/TargetLibraryInfo.h
>   include/llvm/Transforms/Utils/SimplifyLibCalls.h
>   lib/Analysis/TargetLibraryInfo.cpp
>   lib/Transforms/Utils/SimplifyLibCalls.cpp
>   test/Transforms/InstCombine/fp-classify-libcalls.ll
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160330/f7e900f2/attachment.html>


More information about the llvm-commits mailing list