Skip to content

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

Open
@peabody-korg

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions