[PATCH] D64746: Add constrained intrinsics for lrint and lround

Ulrich Weigand via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 15 11:06:51 PST 2022


uweigand added a comment.

In D64746#3323792 <https://reviews.llvm.org/D64746#3323792>, @nlopes wrote:

> Hi,
>
> The semantics described by patch for `lrint` regarding the rounding mode is a bit peculiar and different from all the other constrained FP instrinsics.
> It says:
>
>   The rounding mode is described, not determined, by the rounding mode argument. The actual rounding mode is determined by the runtime floating-point environment. The rounding mode argument is only intended as information to the compiler.
>
> So does this means that the only accepted rounding mode is !dynamic? Why is `lrint` different from the remaining intrinsics?
>
> I was trying to implement the semantics of lrint in Alive2 and came across this discrepancy.
>
> Thanks!

I believe the quoted statement above is both correct __and__ also identical to the semantics of the rounding mode argument of all other constrained intrinsics.  For all of them, the rounding mode argument is a **promise** by the user to the compiler, not an instruction to the compiler to change anything about the rounding mode.   All of these operations will actually use the current default rounding mode, but the presence of a constrained rounding mode argument is an implicit promise by the user to the compiler that the current rounding mode has been set up in a particular way, and the compiler (e.g. for optimization purposes) may rely on that promise.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64746/new/

https://reviews.llvm.org/D64746



More information about the llvm-commits mailing list