/* $Id: transformations.c 70049 2014-06-03 13:52:49Z vinc17/ypig $ * * Test common transformations. See: * https://gcc.gnu.org/wiki/FloatingPointMath * * For x / C where C is a power of 2, see file "div-by-powof2.c". * * The simplication is done except when it violates some flag: * SNAN means HONOR_SNANS (-fsignaling-nans) * NAN means HONOR_NANS (-fno-finite-math-only [default]) * SZ means HONOR_SIGNED_ZEROS (-fsigned-zeros [default]) * RM means HONOR_SIGN_DEPENDENT_ROUNDING (-frounding-math) * * A NAN violation implies a SNAN violation. * * SZ+RM means that both HONOR_SIGNED_ZEROS and HONOR_SIGN_DEPENDENT_ROUNDING * must be true to be violated and disable the transformation. * * With gcc 4.10.0 20140508 [trunk revision 210211], neither x_add_zero, * nor x_sub_zero transformations violate SNAN, which is a bug. * * To check the fold-const.c implementation: * x_add_zero, x_sub_zero: fold_real_zero_addition_p */ /* For asm comparison with the following. */ double id (double x) { return x; } /* Violates */ double x_add_zero (double x) { return x + 0.0; } /* SNAN, SZ */ double x_sub_zero (double x) { return x - 0.0; } /* SNAN, SZ+RM */ double zero_sub_x (double x) { return 0.0 - x; } /* SNAN, SZ */ double zero_mul_x (double x) { return 0.0 * x; } /* NAN, SZ */ double zero_div_x (double x) { return 0.0 / x; } /* NAN, SZ */ double x_mul_one (double x) { return x * 1.0; } /* SNAN */ double x_mul_mone (double x) { return x * -1.0; } /* SNAN */ double x_div_one (double x) { return x / 1.0; } /* SNAN */ double x_div_mone (double x) { return x / -1.0; } /* SNAN */