@@ -3057,11 +3057,14 @@ ix86_expand_int_movcc (rtx operands[])
{
gcc_assert (!DECIMAL_FLOAT_MODE_P (cmp_mode));
- /* We may be reversing unordered compare to normal compare, that
- is not valid in general (we may convert non-trapping condition
- to trapping one), however on i386 we currently emit all
- comparisons unordered. */
- new_code = reverse_condition_maybe_unordered (code);
+ /* We may be reversing a non-trapping
+ comparison to a trapping comparison. */
+ if (HONOR_NANS (cmp_mode) && flag_trapping_math
+ && code != EQ && code != NE
+ && code != ORDERED && code != UNORDERED)
+ new_code = UNKNOWN;
+ else
+ new_code = reverse_condition_maybe_unordered (code);
}
else
new_code = ix86_reverse_condition (code, cmp_mode);
@@ -3213,11 +3216,15 @@ ix86_expand_int_movcc (rtx operands[])
{
gcc_assert (!DECIMAL_FLOAT_MODE_P (cmp_mode));
- /* We may be reversing unordered compare to normal compare,
- that is not valid in general (we may convert non-trapping
- condition to trapping one), however on i386 we currently
- emit all comparisons unordered. */
- new_code = reverse_condition_maybe_unordered (code);
+ /* We may be reversing a non-trapping
+ comparison to a trapping comparison. */
+ if (HONOR_NANS (cmp_mode) && flag_trapping_math
+ && code != EQ && code != NE
+ && code != ORDERED && code != UNORDERED)
+ new_code = UNKNOWN;
+ else
+ new_code = reverse_condition_maybe_unordered (code);
+
}
else
{
new file mode 100644
@@ -0,0 +1,28 @@
+/* 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;
+}