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

sign(float64<N>) generates incorrect code on NEON64 using gcc 9.3.0 with -ffast-math #153

Open
peabody-korg opened this issue Mar 3, 2021 · 0 comments

Comments

@peabody-korg
Copy link
Contributor

auto foo24(float64x2 a) { return sign(a); }

generates:

0000000000000000 <Inspiration::foo24(Inspiration::FloatVectorBase<simdpp::arch_neonfltsp::float64<4u, void> >)>:
   0:	6f00e402 	movi	v2.2d, #0x0
   4:	d10383ff 	sub	sp, sp, #0xe0
   8:	910383ff 	add	sp, sp, #0xe0
   c:	4e221c00 	and	v0.16b, v0.16b, v2.16b
  10:	4e221c21 	and	v1.16b, v1.16b, v2.16b
  14:	d65f03c0 	ret

The problem seems to trace back to the way bit_and() is being processed in the implementation of _i_sign(float64):

    return bit_and(a, 0x8000000000000000);

The 0x8000000'00000000 constant gets bit-converted to the floating point constant -0.0. Because of -ffast-math -0.0 and 0.0 are equivalent, so this winds up masking with 0 instead.

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

No branches or pull requests

1 participant