This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFApproval, trunk] Optimization of Complex OP Real.
L.S.,
Here's the improved patch, including all Richards recommendations and
silencing the bleating of the sheep (i.e., -Wparentheses);
Bootstrapped C and Fortran only, make check Fortran and a comparison of
Fortran output of a run with the clean compiler with the updated one on
LAPACK (using their checking procedures).
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)
2002-05-18 Toon Moene <toon@moene.indiv.nluug.nl>
* optabs.c (complex_part_zero_p): New.
* (expand_cmplxdiv_straight): Use.
* (expand_cmplxdiv_wide): Ditto.
* (expand_binop): Ditto.
*** optabs.c.orig Sun Mar 31 13:29:17 2002
--- optabs.c Sat May 18 10:46:56 2002
*************** static optab new_optab PARAMS ((void));
*** 109,112 ****
--- 109,114 ----
static inline optab init_optab PARAMS ((enum rtx_code));
static inline optab init_optabv PARAMS ((enum rtx_code));
+ static inline int complex_part_zero_p PARAMS ((rtx, enum mode_class,
+ enum machine_mode));
static void init_libfuncs PARAMS ((optab, int, int, const char *, int));
static void init_integral_libfuncs PARAMS ((optab, const char *, int));
*************** widen_operand (op, mode, oldmode, unsign
*** 213,216 ****
--- 215,234 ----
}
+ /* Test whether either the real or imaginary part of a complex floating
+ point number is 0.0, so that it can be ignored (when compiling
+ with -funsafe-math-optimizations). */
+
+ static inline int
+ complex_part_zero_p (part, class, submode)
+ rtx part;
+ enum mode_class class;
+ enum machine_mode submode;
+ {
+ return part == 0 ||
+ (flag_unsafe_math_optimizations
+ && class == MODE_COMPLEX_FLOAT
+ && part == CONST0_RTX (submode));
+ }
+
/* Generate code to perform a straightforward complex divide. */
*************** expand_cmplxdiv_straight (real0, real1,
*** 266,270 ****
return 0;
! if (imag0 == 0)
{
/* Mathematically, ((a)(c-id))/divisor. */
--- 284,288 ----
return 0;
! if (complex_part_zero_p (imag0, class, submode))
{
/* Mathematically, ((a)(c-id))/divisor. */
*************** expand_cmplxdiv_wide (real0, real1, imag
*** 432,436 ****
/* Calculate dividend. */
! if (imag0 == 0)
{
real_t = real0;
--- 450,454 ----
/* Calculate dividend. */
! if (complex_part_zero_p (imag0, class, submode))
{
real_t = real0;
*************** expand_binop (mode, binoptab, op0, op1,
*** 1658,1662 ****
/* (a+ib) / (c+id) = ((ac+bd)/(cc+dd)) + i((bc-ad)/(cc+dd)) */
! if (imag1 == 0)
{
/* (a+ib) / (c+i0) = (a/c) + i(b/c) */
--- 1676,1680 ----
/* (a+ib) / (c+id) = ((ac+bd)/(cc+dd)) + i((bc-ad)/(cc+dd)) */
! if (complex_part_zero_p (imag1, class, submode))
{
/* (a+ib) / (c+i0) = (a/c) + i(b/c) */