[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 13:04:13 PST 2022


nlopes added a comment.

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

> In D64746#3323899 <https://reviews.llvm.org/D64746#3323899>, @nlopes wrote:
>
>> In D64746#3323862 <https://reviews.llvm.org/D64746#3323862>, @uweigand wrote:
>>
>>> 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.
>
> This matches my understanding.   (Though I must admit I'm not 100% confident I fully understand the precise distinction between "undefined behavior", a poison value, and an undef value ...  It's certainly one of those :-)  But from my reading of the IR reference, "poison" does indeed look correct here.)

OK, thank you!
It's poison. UB would be too strong. I've put on my todo list to fix LangRef as well.


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

https://reviews.llvm.org/D64746



More information about the llvm-commits mailing list