Hello,

the attached patch fixes PR:s c/35162 (just a documentation fix) and
fortran/29549.

c/35162 is just a small documentation fix where the documentation was
inconsistent with the code as well as C99.

It adds a new option -fcx-fortran-rules which sets flag_complex_method
to 1, and makes libgfortran use that switch, gaining a factor of 4
speedup on complex matrix multplication.

Regtested on i686-pc-linux-gnu, doc changes tested with 'make info' and
'make pdf'. Ok for trunk?

-- 
Janne Blomqvist
gcc ChangeLog:
        
2008-02-19  Janne Blomqvist  <[EMAIL PROTECTED]>

        PR fortran/29549
        PR c/35162
        
        * doc/invoke.texi (-fcx-limited-range): Correct to be in line with
        actual behaviour and C99.
        (-fcx-fortran-rules): Document new option.
        * toplev.c (process_options): Handle -fcx-fortran-rules.
        * common.opt: Add documentation for -fcx-fortran-rules

        
libgfortran ChangeLog:

2008-02-19  Janne Blomqvist  <[EMAIL PROTECTED]>

        PR fortran/29549

        * Makefile.am: Add -fcx-fortran-rules to AM_CFLAGS for all of
        libgfortran.
        * Makefile.in: Regenerated.
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi	(revision 132440)
+++ gcc/doc/invoke.texi	(working copy)
@@ -320,7 +320,8 @@ Objective-C and Objective-C++ Dialects}.
 -fauto-inc-dec -fbranch-probabilities -fbranch-target-load-optimize @gol
 -fbranch-target-load-optimize2 -fbtr-bb-exclusive -fcaller-saves @gol
 -fcheck-data-deps -fcprop-registers -fcrossjumping -fcse-follow-jumps @gol
--fcse-skip-blocks -fcx-limited-range -fdata-sections -fdce -fdce @gol
+-fcse-skip-blocks -fcx-fortran-rules -fcx-limited-range @gol
+-fdata-sections -fdce -fdce @gol
 -fdelayed-branch -fdelete-null-pointer-checks -fdse -fdse @gol
 -fearly-inlining -fexpensive-optimizations -ffast-math @gol
 -ffinite-math-only -ffloat-store -fforward-propagate @gol
@@ -6541,13 +6542,25 @@ implicitly converting it to double preci
 @item -fcx-limited-range
 @opindex fcx-limited-range
 When enabled, this option states that a range reduction step is not
-needed when performing complex division.  The default is
[EMAIL PROTECTED], but is enabled by @option{-ffast-math}.
+needed when performing complex division.  Also, there is no checking
+whether the result of a complex multiplication or division is NaN +
+I*NaN, with an attempt to rescue the situation in that case.
+The default is @option{-fno-cx-limited-range}, but is enabled by
[EMAIL PROTECTED]
 
 This option controls the default setting of the ISO C99
 @code{CX_LIMITED_RANGE} pragma.  Nevertheless, the option applies to
 all languages.
 
[EMAIL PROTECTED] -fcx-fortran-rules
[EMAIL PROTECTED] fcx-fortran-rules
+Complex multiplication and division follow Fortran rules.  Range
+reduction is done as part of complex division, but there is no checking
+whether the result of a complex multiplication or division is NaN +
+I*NaN, with an attempt to rescue the situation in that case.
+
+The default is @option{-fno-cx-fortran-rules}.
+
 @end table
 
 The following options control optimizations that may improve
Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c	(revision 132440)
+++ gcc/toplev.c	(working copy)
@@ -2001,6 +2001,10 @@ process_options (void)
   if (flag_cx_limited_range)
     flag_complex_method = 0;
 
+  /* With -fcx-fortran-rules, we do something in-between cheap and C99.  */
+  if (flag_cx_fortran_rules)
+    flag_complex_method = 1;
+
   /* Targets must be able to place spill slots at lower addresses.  If the
      target already uses a soft frame pointer, the transition is trivial.  */
   if (!FRAME_GROWS_DOWNWARD && flag_stack_protect)
Index: gcc/common.opt
===================================================================
--- gcc/common.opt	(revision 132440)
+++ gcc/common.opt	(working copy)
@@ -390,6 +390,10 @@ fcx-limited-range
 Common Report Var(flag_cx_limited_range) Optimization
 Omit range reduction step when performing complex division
 
+fcx-fortran-rules
+Common Report Var(flag_cx_fortran_rules) Optimization
+Complex multiplication and division follow Fortran rules
+
 fdata-sections
 Common Report Var(flag_data_sections) Optimization
 Place data items into their own section
Index: libgfortran/Makefile.am
===================================================================
--- libgfortran/Makefile.am	(revision 132440)
+++ libgfortran/Makefile.am	(working copy)
@@ -28,6 +28,9 @@ AM_CPPFLAGS = -iquote$(srcdir)/io -I$(sr
 	      -I$(srcdir)/$(MULTISRCTOP)../gcc/config \
 	      -I$(MULTIBUILDTOP)../../$(host_subdir)/gcc -D_GNU_SOURCE
 
+# Fortran rules for complex multiplication and division
+AM_CFLAGS += -fcx-fortran-rules
+
 gfor_io_src= \
 io/close.c \
 io/file_pos.c \
Index: libgfortran/Makefile.in
===================================================================
--- libgfortran/Makefile.in	(revision 132440)
+++ libgfortran/Makefile.in	(working copy)
@@ -730,7 +730,9 @@ ACLOCAL = @ACLOCAL@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
-AM_CFLAGS = @AM_CFLAGS@
+
+# Fortran rules for complex multiplication and division
+AM_CFLAGS = @AM_CFLAGS@ -fcx-fortran-rules
 AM_FCFLAGS = @AM_FCFLAGS@
 AR = @AR@
 AS = @AS@
@@ -789,13 +791,9 @@ SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
 VERSION = @VERSION@
-ac_ct_AR = @ac_ct_AR@
-ac_ct_AS = @ac_ct_AS@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
 ac_ct_FC = @ac_ct_FC@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_STRIP = @ac_ct_STRIP@
 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
 am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
 am__include = @am__include@
@@ -812,6 +810,9 @@ build_os = @build_os@
 build_subdir = @build_subdir@
 build_vendor = @build_vendor@
 datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
 enable_shared = @enable_shared@
 enable_static = @enable_static@
 exec_prefix = @exec_prefix@
@@ -822,11 +823,13 @@ host_cpu = @host_cpu@
 host_os = @host_os@
 host_subdir = @host_subdir@
 host_vendor = @host_vendor@
+htmldir = @htmldir@
 includedir = @includedir@
 infodir = @infodir@
 install_sh = @install_sh@
 libdir = @libdir@
 libexecdir = @libexecdir@
+localedir = @localedir@
 localstatedir = @localstatedir@
 lt_ECHO = @lt_ECHO@
 mandir = @mandir@
@@ -836,8 +839,10 @@ oldincludedir = @oldincludedir@
 onestep = @onestep@
 onestep_FALSE = @onestep_FALSE@
 onestep_TRUE = @onestep_TRUE@
+pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
+psdir = @psdir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 sysconfdir = @sysconfdir@

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to