This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
New update to optabs.c for optimizing C op R expressions.
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 29 Jun 2002 18:18:43 +0200
- Subject: New update to optabs.c for optimizing C op R expressions.
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
L.S.,
The attached patch shows at least some optimizing behaviour when
presented with the following source code:
COMPLEX FUNCTION CF(C, R)
COMPLEX C
REAL R
CF = C * R
RETURN
END
Please approve.
[ Normally, four multiplications have to be performed but with this
patch (and the -ffast-math option) those have been reduced to two. ]
Note that -ffast-math is overkill here - what we would need is a
-ffinite-math switch, that indicated that only finite floating point
math is supported. g77 then could set this flag by default (due to the
definition of the Fortran Language).
Thanks in advance,
--
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-06-29 Toon Moene <toon@moene.indiv.nluug.nl>
* optabs.c (complex_part_zero_p): Do not test for
CONSTO_RTX, but for EQUALity to dconst0.
*** optabs.c.orig Sat Jun 29 13:28:42 2002
--- optabs.c Sat Jun 29 14:15:49 2002
*************** complex_part_zero_p (part, class, submod
*** 252,259 ****
enum machine_mode submode;
{
! return part == 0 ||
! (flag_unsafe_math_optimizations
! && class == MODE_COMPLEX_FLOAT
! && part == CONST0_RTX (submode));
}
--- 252,271 ----
enum machine_mode submode;
{
! if (part == 0)
! return 1;
!
! if (flag_unsafe_math_optimizations
! && class == MODE_COMPLEX_FLOAT
! && GET_CODE (part) == CONST_DOUBLE)
! {
! REAL_VALUE_TYPE r;
!
! REAL_VALUE_FROM_CONST_DOUBLE (r, part);
! r = real_value_truncate (submode, r);
!
! return REAL_VALUES_EQUAL (r, dconst0);
! }
!
! return 0;
}