[cfe-dev] ARMv7 float->int rounding
Joerg Sonnenberger via cfe-dev
cfe-dev at lists.llvm.org
Fri Feb 19 07:43:08 PST 2016
On Thu, Feb 18, 2016 at 02:40:43PM +0100, Domagoj Saric via cfe-dev wrote:
> std::int32_t round( float const floatingPointValue )
> {
> #if A
> return __builtin_lrintf( floatingPointValue );
lrint is not optimised on any platforms AFAICT, x86 has a small note
about it.
> #elif B
> std::int32_t integerValue;
> __asm__
> (
> "vcvtr.s32.f32 %0, %1" : "=w"( integerValue ) : "w"( floatingPointValue );
> );
> return integerValue;
This doesn't work because the types are wrong. You want to do something
like
"vcvtr.s32.f32 %1, %1; vmov %0, %1"
or so with =r for the integerValue. Not sure why this is not caught in
the frontend already.
> #elif C
> return __builtin_arm_vcvtr_f( floatingPointValue, 0 );
WFM
Joerg
More information about the cfe-dev
mailing list