This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Improve initial RTL for squaring a complex number.
- From: Roger Sayle <roger at eyesopen dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 1 Jun 2003 12:25:23 -0600 (MDT)
- Subject: [PATCH] Improve initial RTL for squaring a complex number.
The following patch improves the initial RTL that GCC generates for
squaring a complex value. It turns out that the extra multiplication
eventually gets recognized by common subexpression elimination,
however the following patch reduces the number of insns we initially
generate and the number of pseudo registers we need.
The following patch has been bootstrapped on i686-pc-linux-gnu with
a complete "make bootstrap", all languages except treelang, and
regression tested with a top-level "make -k check" with no new
failures.
Ok for mainline?
2003-06-01 Roger Sayle <roger@eyesopen.com>
* optabs.c (expand_binop): Optimize complex multiplication for
the case of squaring a complex argument.
Index: optabs.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/optabs.c,v
retrieving revision 1.172
diff -c -3 -p -r1.172 optabs.c
*** optabs.c 15 Apr 2003 13:06:58 -0000 1.172
--- optabs.c 1 Jun 2003 14:46:53 -0000
*************** expand_binop (mode, binoptab, op0, op1,
*** 1638,1645 ****
temp1 = expand_binop (submode, binoptab, real0, imag1,
NULL_RTX, unsignedp, methods);
! temp2 = expand_binop (submode, binoptab, real1, imag0,
! NULL_RTX, unsignedp, methods);
if (temp1 == 0 || temp2 == 0)
break;
--- 1638,1650 ----
temp1 = expand_binop (submode, binoptab, real0, imag1,
NULL_RTX, unsignedp, methods);
! /* Avoid expanding redundant multiplication for the common
! case of squaring a complex number. */
! if (rtx_equal_p (real0, real1) && rtx_equal_p (imag0, imag1))
! temp2 = temp1;
! else
! temp2 = expand_binop (submode, binoptab, real1, imag0,
! NULL_RTX, unsignedp, methods);
if (temp1 == 0 || temp2 == 0)
break;
Roger
--
Roger Sayle, E-mail: roger@eyesopen.com
OpenEye Scientific Software, WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road, Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507. Fax: (+1) 505-473-0833