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.
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 09 May 2002 21:47:51 +0200
- Subject: Re: [RFApproval, trunk] Optimization of Complex OP Real.
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
- References: <3CDAC34E.F700651D@moene.indiv.nluug.nl>
I wrote:
> Several times in the past year I've been asked when g77 would support
> the optimization that eliminates the superfluous instructions that
> result from adding, multiplying by or dividing zero when Complex OP Real
> deals with its imaginary part.
>
> This patch is a first shot at this optimization [obviously, it can only
> be applied under "unsafe-math" assumptions]. Passes make bootstrap (C
> and Fortran only), make check and make install on i686-pc-linux-gnu. It
> also passes a comparison with mainline gcc/g77 (using -O2 -ffast-math)
> compiling and checking LAPACK.
>
> OK to install on mainline ?
As several people have pointed out - I forgot to include the patch ;-)
Must be my age ...
T-t-t-talking ab-b-b-out my c-c-code g-g-generation ...
--
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-09 Toon Moene <toon@moene.indiv.nluug.nl>
* optabs.c (COMPLEX_{REAL|IMAG}_PART_ZERO_P): New macros
to facilitate complex optimization.
* (expand_cmplxdiv_straight): Use it.
* (expand_cmplxdiv_wide): Ditto.
*** optabs.c.orig Sun Mar 31 13:29:17 2002
--- optabs.c Thu May 9 15:11:26 2002
*************** Software Foundation, 59 Temple Place - S
*** 42,45 ****
--- 42,57 ----
#include "real.h"
+ /* Macros to simplify Complex OP Real decisions */
+
+ #define COMPLEX_REAL_PART_ZERO_P(REAL, CLASS) ((REAL) == 0 || \
+ flag_unsafe_math_optimizations \
+ && (CLASS) == MODE_COMPLEX_FLOAT \
+ && (REAL) == const0_rtx)
+
+ #define COMPLEX_IMAG_PART_ZERO_P(IMAG, CLASS) ((IMAG) == 0 || \
+ flag_unsafe_math_optimizations \
+ && (CLASS) == MODE_COMPLEX_FLOAT \
+ && (IMAG) == const0_rtx)
+
/* Each optab contains info on how this target machine
can perform a particular operation
*************** expand_cmplxdiv_straight (real0, real1,
*** 266,270 ****
return 0;
! if (imag0 == 0)
{
/* Mathematically, ((a)(c-id))/divisor. */
--- 278,282 ----
return 0;
! if (COMPLEX_IMAG_PART_ZERO_P (imag0, class))
{
/* Mathematically, ((a)(c-id))/divisor. */
*************** expand_cmplxdiv_wide (real0, real1, imag
*** 432,436 ****
/* Calculate dividend. */
! if (imag0 == 0)
{
real_t = real0;
--- 444,448 ----
/* Calculate dividend. */
! if (COMPLEX_IMAG_PART_ZERO_P (imag0, class))
{
real_t = real0;
*************** expand_cmplxdiv_wide (real0, real1, imag
*** 537,541 ****
/* Calculate dividend. */
! if (imag0 == 0)
{
/* Compute a / (c+id) as a(c/d) / (c(c/d)+d) + i (-a) / (c(c/d)+d). */
--- 549,553 ----
/* Calculate dividend. */
! if (COMPLEX_IMAG_PART_ZERO_P (imag0, class))
{
/* Compute a / (c+id) as a(c/d) / (c(c/d)+d) + i (-a) / (c(c/d)+d). */
*************** 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) */
--- 1670,1674 ----
/* (a+ib) / (c+id) = ((ac+bd)/(cc+dd)) + i((bc-ad)/(cc+dd)) */
! if (COMPLEX_IMAG_PART_ZERO_P (imag1, class))
{
/* (a+ib) / (c+i0) = (a/c) + i(b/c) */