https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96793
--- Comment #20 from Uroš Bizjak <ubizjak at gmail dot com> --- https://gcc.gnu.org/g:0bf0e0b86d3e2f12555479096baaf0ca7a9f7ac6 commit r10-9164-g0bf0e0b86d3e2f12555479096baaf0ca7a9f7ac6 Author: Uros Bizjak <ubiz...@gmail.com> Date: Tue Dec 22 21:11:51 2020 +0100 i386: Fix __builtin_floor with FE_DOWNWARD rounding direction [PR96793] x86_expand_floorceil expander uses x86_sse_copysign_to_positive, which is unable to change the sign from - to +. When FE_DOWNWARD rounding direction is in effect, the expanded sequence that involves subtraction can trigger x - x = -0.0 special rule. x86_sse_copysign_to_positive fails to change the sign of the intermediate value, assumed to always be positive, back to positive. The patch adds one extra fabs that strips the sign from the intermediate value when flag_rounding_math is in effect. 2020-12-22 Uroš Bizjak <ubiz...@gmail.com> gcc/ PR target/96793 * config/i386/i386-expand.c (ix86_expand_floorceil): Remove the sign of the intermediate value for flag_rounding_math. (ix86_expand_floorceildf_32): Ditto. gcc/testsuite/ PR target/96793 * gcc.target/i386/pr96793.c: New test.