[patch, fortran, 4.5] F2003: simplifiers for array transformations

Daniel Franke franke.daniel@gmail.com
Sat Jan 3 17:21:00 GMT 2009


Hi all.

This somewhat lengthy patch adds simplification support for transformational 
functions that reduce arrays. This allows to use the intrinsics SUM, PRODUCT, 
ANY, ALL, MINVAL and MAXVAL in initialization expressions as specified by 
Fortran 2003.

With this, the functions ALL, ANY, PRODUCT and SUM are newly supported. The 
existing simplifiers of MAXVAL and MINVAL have been extended to accept the 
optional DIM argument. While at it, MAX and MIN have been reworked to use the 
same transformational operators as MAXVAL and MINVAL. The latter now also 
accept character arguments.

Please note, character arguments in MAXVAL/MINVAL are now supported for 
initialization expressions, but are not properly translated yet if 
simplification doesn't apply (see change in trans-intrinsic.c).

There are no specific testcases for ALL and ANY as there are some implicit 
checks in the tests and the code paths are virtually the same.

Bootstrapped and regression tested on i686-pc-linux-gnu. Tested html-target 
for doc changes. Ok for 4.5?

Regards

	Daniel


P.S. As time permits, I plan to work on TRANSPOSE, MATMUL and DOT_PRODUCT 
next.


2009-01-03  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/29962
	* gfortran.h (gfc_wide_strcpy): New prototype.
	* scanner.c (wide_strcpy): Renamed to ...
	(gfc_wide_strcpy): ... this. Fixed all callers.
	* simplify.c (init_result_expr): New.
	(trans_result): New.
	(simplify_trans_scalar): New.
	(simplify_trans_array): New.
	(trans_op_and): New.
	(trans_op_or): New.
	(trans_op_sum): New.
	(trans_op_product): New.
	(trans_op_max): New.
	(trans_op_min): New.
	(min_max_choose): Removed.
	(gfc_simplify_all): New.
	(gfc_simplify_any): New.
	(gfc_simplify_product): New.
	(gfc_simplify_sum): New.
	(gfc_simplify_max): Reimplemented to use transformational operator.
	(gfc_simplify_min): Likewise.
	(gfc_simplify_maxval): Likewise.
	(gfc_simplify_minval): Likewise.
	* intrinsic.h (gfc_simplify_all): New prototype.
	(gfc_simplify_any): New prototype.
	(gfc_simplify_product): New prototype.
	(gfc_simplify_sum): New prototype.
	* intrinsic.c (add_functions): Added new simplification callbacks.
	* check.c (dim_rank_rank): Added NULL-pointer check for DIM.
	(gfc_check_all_any): Also check rank of DIM.
	(gfc_check_min_max): Replaced explicit check by equivalent function call.
	(gfc_check_minval_maxval): Allow character arguments if std=f2003.
	(gfc_check_lbound): Removed redundant check for NULL on DIM.
	(gfc_check_minloc_maxloc): Likewise.
	(check_reduction): Likewise.
	(gfc_check_size): Likewise.
	(gfc_check_ubound): Likewise.
	* trans-intrinsic.c (gfc_conv_intrinsic_minmaxval): Replaced assert with
	fatal error if called with character arguments.
	* expr.c (check_inquiry): Fixed check for applicable standard.
	(check_transformational): List transformational intrinsics with
	simplifications.
	* intrinsic.texi (COUNT): Clarified documentation.
	(MAX): List CHARACTER arguments allowed by F2003, added example.
	(MIN): Likewise.
	(MAXVAL): Clarified that CHARACTER arguments are only allowed by F2003.
	(MINVAL): Likewise.
	

gcc/testsuite:
2009-01-03 Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/29962
	* gfortran.dg/minmaxval_2.f90 New.
	* gfortran.dg/product_init_expr.f90: New.
	* gfortran.dg/sum_init_expr.f90: New.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr29962.diff
Type: text/x-patch
Size: 51018 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20090103/faffd8c2/attachment.bin>


More information about the Fortran mailing list