Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<cmath>: Use ceil/floor/round/etc. intrinsics #1234

Open
StephanTLavavej opened this issue Aug 27, 2020 · 2 comments
Open

<cmath>: Use ceil/floor/round/etc. intrinsics #1234

StephanTLavavej opened this issue Aug 27, 2020 · 2 comments
Labels
performance Must go faster

Comments

@StephanTLavavej
Copy link
Member

StephanTLavavej commented Aug 27, 2020

In VS 2019 16.8 Preview 3, the following intrinsics will be available (MS-internal MSVC-PR-265316):

double __ceil(double);
float __ceilf(float);
double __floor(double);
float __floorf(float);
double __round(double);
float __roundf(float);
double __trunc(double);
float __truncf(float);
double __copysign(double, double);
float __copysignf(float, float);
unsigned int __signbitvalue(double);
unsigned int __signbitvaluef(float);

These are available for all architectures, declared in <intrin0.h>. We should take advantage of them. (We may need to report this to the UCRT too.)

Also tracked by DevCom-987080 (MS-internal VSO-1101527 / AB#1101527) and DevCom-1038270 (MS-internal VSO-1129605 / AB#1129605).

@statementreply
Copy link
Contributor

statementreply commented Aug 27, 2020

Precaution: maybe we should verify that __round/__roundf uses the rounding mode of std::round, not FE_NEAREST, on all architectures/ISAs//archs, before using it.

From OP of DevCom-1038270:

round = _MM_FROUND_TO_NEAREST_INT

If __round implements this rounding mode, it couldn't be used when the rounding behavior of std::round is required.

@sylveon
Copy link
Contributor

sylveon commented Oct 1, 2020

After investigating, the only place where this can be applied from the STL's side is the handwritten float overloads. Functions with a f suffix and the double versions are from the UCRT.

I believe a best solution would be to give intrinsic value to those functions to the compiler (for example like how memcpy is).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
None yet
Development

No branches or pull requests

3 participants