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

Nuno Lopes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 15 11:18:08 PST 2022


nlopes added a comment.

In D64746#3323862 <https://reviews.llvm.org/D64746#3323862>, @uweigand wrote:

> 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.

Thank you.
Can I read what you wrote as "if the rounding mode argument is not !dynamic and if it differs from the run-time rounding mode, the intrinsic returns poison"?

Essentially you want to allow the compiler to use the given rounding mode for optimizations, but still be able to lower the intrinsic to a single libcall that will use the run-time rounding mode, not the one given as argument.


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

https://reviews.llvm.org/D64746



More information about the llvm-commits mailing list