https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96793
--- Comment #13 from Marc Glisse <glisse at gcc dot gnu.org> --- x-x does depend on the rounding mode (the transformation in match.pd gets it wrong, by the way). If the sign of 0 is the only issue, maybe we can test flag_rounding_math && flag_signed_zeros or the corresponding HONOR_*(mode)? There are sensible cases where rounding matters but not the sign of 0. As for making the sequence always work... I am not sure there is much better than if(x2==0)x2=0;. We could also compute -1 in type long (the test isless should already guarantee that there is no overflow?), that means an extra conversion from long to double. I see that ix86_expand_floorceildf_32 already ends with if (HONOR_SIGNED_ZEROS (mode)) x2 = copysign (x2, x); so we could also add that to ix86_expand_floorceil.