Commit ddfb80ad by Uros Bizjak

i386: Avoid reversing a non-trapping comparison to a trapping one [PR95169]

2020-05-21  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:
	PR target/95169
	* config/i386/i386-expand.c (ix86_expand_int_movcc):
	 Avoid reversing a non-trapping comparison to a trapping one.

gcc/testsuite/ChangeLog:
	PR target/95169
	* gcc.target/i386/pr95169.c: New test.
parent a321683b
2020-05-21 Uroš Bizjak <ubizjak@gmail.com>
PR target/95169
* config/i386/i386-expand.c (ix86_expand_int_movcc):
Avoid reversing a non-trapping comparison to a trapping one.
2020-05-21 Martin Liska <mliska@suse.cz> 2020-05-21 Martin Liska <mliska@suse.cz>
* common/config/aarch64/aarch64-common.c (aarch64_handle_option): * common/config/aarch64/aarch64-common.c (aarch64_handle_option):
......
...@@ -3059,10 +3059,13 @@ ix86_expand_int_movcc (rtx operands[]) ...@@ -3059,10 +3059,13 @@ ix86_expand_int_movcc (rtx operands[])
{ {
gcc_assert (!DECIMAL_FLOAT_MODE_P (cmp_mode)); gcc_assert (!DECIMAL_FLOAT_MODE_P (cmp_mode));
/* We may be reversing unordered compare to normal compare, that /* We may be reversing a non-trapping
is not valid in general (we may convert non-trapping condition comparison to a trapping comparison. */
to trapping one), however on i386 we currently emit all if (HONOR_NANS (cmp_mode) && flag_trapping_math
comparisons unordered. */ && code != EQ && code != NE
&& code != ORDERED && code != UNORDERED)
new_code = UNKNOWN;
else
new_code = reverse_condition_maybe_unordered (code); new_code = reverse_condition_maybe_unordered (code);
} }
else else
...@@ -3215,11 +3218,15 @@ ix86_expand_int_movcc (rtx operands[]) ...@@ -3215,11 +3218,15 @@ ix86_expand_int_movcc (rtx operands[])
{ {
gcc_assert (!DECIMAL_FLOAT_MODE_P (cmp_mode)); gcc_assert (!DECIMAL_FLOAT_MODE_P (cmp_mode));
/* We may be reversing unordered compare to normal compare, /* We may be reversing a non-trapping
that is not valid in general (we may convert non-trapping comparison to a trapping comparison. */
condition to trapping one), however on i386 we currently if (HONOR_NANS (cmp_mode) && flag_trapping_math
emit all comparisons unordered. */ && code != EQ && code != NE
&& code != ORDERED && code != UNORDERED)
new_code = UNKNOWN;
else
new_code = reverse_condition_maybe_unordered (code); new_code = reverse_condition_maybe_unordered (code);
} }
else else
{ {
......
2020-05-21 Uroš Bizjak <ubizjak@gmail.com>
PR target/95169
* gcc.target/i386/pr95169.c: New test.
2020-05-21 Martin Liska <mliska@suse.cz> 2020-05-21 Martin Liska <mliska@suse.cz>
* gcc.target/aarch64/target_attr_20.c: New test. * gcc.target/aarch64/target_attr_20.c: New test.
......
/* PR target/95169 */
/* { dg-do run { target ia32 } } */
/* { dg-options "-O0 -march=i386 -mtune=generic" } */
/* { dg-require-effective-target fenv_exceptions } */
#include <fenv.h>
void
f (double y)
{
if (__builtin_expect (y == 0.0, 0))
__builtin_abort ();
}
int
main (void)
{
double y = __builtin_nan ("");
feclearexcept (FE_INVALID);
f (y);
if (fetestexcept (FE_INVALID))
__builtin_abort ();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment