]> git.ipfire.org Git - thirdparty/gcc.git/commit
i386: Fix __builtin_trunc with FE_DOWNWARD rounding direction [PR96793]
authorUros Bizjak <ubizjak@gmail.com>
Wed, 23 Dec 2020 17:32:28 +0000 (18:32 +0100)
committerUros Bizjak <ubizjak@gmail.com>
Wed, 23 Dec 2020 17:32:28 +0000 (18:32 +0100)
commita5bcb9487dd62b853a6813387309e5f83a47ce0d
tree0b5c0fef196182dc84be1813b762dc364ed1ee91
parent65fcf1c2d7f192dc7fda621e27d6c17d08e89352
i386: Fix __builtin_trunc with FE_DOWNWARD rounding direction [PR96793]

x86_expand_truncdf_32 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-23  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
PR target/96793
* config/i386/i386-expand.c (ix86_expand_truncdf_32):
Remove the sign of the intermediate value for flag_rounding_math.

gcc/testsuite/
PR target/96793
* gcc.target/i386/pr96793-1.c: New test.
gcc/config/i386/i386-expand.c
gcc/testsuite/gcc.target/i386/pr96793-1.c [new file with mode: 0644]