[libcxx-commits] [PATCH] D115125: [libc++] Avoid rejection sampling in `uniform_int_distribution` if possible

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 6 11:59:32 PST 2021


ldionne added a comment.

In D115125#3174316 <https://reviews.llvm.org/D115125#3174316>, @fwolff wrote:

> In D115125#3172432 <https://reviews.llvm.org/D115125#3172432>, @Quuxplusone wrote:
>
>> My initial reaction is that this change slows down the common case to cater to a really super pathological case; I don't think we should do it (but a benchmark could probably change my mind).
>
> OK. This was just a suggestion because there was a bug report about this, and the check definitely gets optimized away for all "common" cases, but I understand your concern.

IMO correctness is more important than performance -- if our implementation is incorrect and we can fix it without introducing a bad performance regression (and that seems to be the case, the branch and the modulo don't seem to be much in comparison to the rest of the algorithm, but I could be wrong), then we should do it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115125



More information about the libcxx-commits mailing list