Hello! Attached patch fixes PR78738 in a different way. The patch enables X87_ENABLE_ARITH and X87_ENABLE_FLOAT also for flag_unsafe_math_optimizations.
2016-12-12 Uros Bizjak <ubiz...@gmail.com> PR target/78738 * config/i386/i386.h (X87_ENABLE_ARITH): Also enable for flag_unsafe_math_optimizations. (X87_ENABLE_FLOAT): Ditto. testsuite/ChangeLog: 2016-12-12 Uros Bizjak <ubiz...@gmail.com> PR target/78738 * gcc.target/i386/pr78738.c: New test. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Committed to mainline SVN. Uros.
Index: config/i386/i386.h =================================================================== --- config/i386/i386.h (revision 243558) +++ config/i386/i386.h (working copy) @@ -693,13 +693,16 @@ /* Whether to allow x87 floating-point arithmetic on MODE (one of SFmode, DFmode and XFmode) in the current excess precision configuration. */ -#define X87_ENABLE_ARITH(MODE) \ - (flag_excess_precision == EXCESS_PRECISION_FAST || (MODE) == XFmode) +#define X87_ENABLE_ARITH(MODE) \ + (flag_unsafe_math_optimizations \ + || flag_excess_precision == EXCESS_PRECISION_FAST \ + || (MODE) == XFmode) /* Likewise, whether to allow direct conversions from integer mode IMODE (HImode, SImode or DImode) to MODE. */ #define X87_ENABLE_FLOAT(MODE, IMODE) \ - (flag_excess_precision == EXCESS_PRECISION_FAST \ + (flag_unsafe_math_optimizations \ + || flag_excess_precision == EXCESS_PRECISION_FAST \ || (MODE) == XFmode \ || ((MODE) == DFmode && (IMODE) == SImode) \ || (IMODE) == HImode) Index: testsuite/gcc.target/i386/pr78738.c =================================================================== --- testsuite/gcc.target/i386/pr78738.c (nonexistent) +++ testsuite/gcc.target/i386/pr78738.c (working copy) @@ -0,0 +1,10 @@ +/* PR middle-end/78738 */ +/* { dg-do compile } */ +/* { dg-options "-O -std=c99 -ffast-math -mfpmath=387" } */ + +double round (double); + +int foo (double a) +{ + return round (a); +}