[PATCH] D27028: Add intrinsics for constrained floating point operations

David Kreitzer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 6 09:10:28 PST 2017


DavidKreitzer added a comment.

In https://reviews.llvm.org/D27028#636346, @andrew.w.kaylor wrote:

> In https://reviews.llvm.org/D27028#635372, @DavidKreitzer wrote:
>
> > When frem has a meaningful result, it is always exact, so perhaps we should omit the rounding behavior argument? I think we still need a constrained frem intrinsic, though, to handle the exceptional behavior in cases such as "frem inf, x" and "frem x, 0".
>
>
> The implementation is slightly simpler if I give the frem intrinsic a rounding argument, even though it isn't needed.  Otherwise, that intrinsic couldn't be handled by the same subclass as the others.  I realize that's a fairly weak argument, but I just feel like making this one intrinsic different from the others will make the code ugly.


Uniformity of implementation is a reasonable argument in favor of the extraneous rounding mode parameter for the frem intrinsic. But could you please make it clear that that is your intent in the language ref description of  @llvm.experimental.constrained.frem?



================
Comment at: docs/LangRef.rst:12147
+
+'``llvm.experimental.constrained.fsub``' Intrinsic
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
----------------
scanon wrote:
> DavidKreitzer wrote:
> > This question might be beyond the scope of this initial change set, but here goes.
> > 
> > FP negation is currently handled using fsub -0, X. Is that sufficient in a constrained context? If we allow X to be a signaling NaN, -0-X should raise Invalid while -X should not, at least according to IEEE-754.
> > 
> Probably more importantly, -X has a defined signbit (the negation of whatever the signbit of X was), but -0-X does not [assuming the obvious binding of -X to the IEEE 754 negate operation and -0-X to the subtract operation].
Steve, are you referring to the fact that the sign of -0-X is unspecified when X is NaN or something else? I am trying to understand the implications of your comment - whether they are specific to the new constrained FP intrinsics or whether something needs to be done for normal FP LLVM IR.

Another problem worth mentioning with implementing -X as -0-X in a constrained context is that -0-X will produce -0 when X is -0 and the rounding mode is toward -inf.




Repository:
  rL LLVM

https://reviews.llvm.org/D27028





More information about the llvm-commits mailing list