aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/frontend-passes.c
AgeCommit message (Collapse)AuthorFilesLines
2011-12-11re PR fortran/50690 (ICE with front end optimization and OMP workshare)Thomas Koenig1-2/+36
2011-12-11 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/50690 * frontend-passes.c (in_omp_workshare): New variable. (cfe_expr_0): Don't eliminiate common function if it would put the variable immediately into a WORKSHARE construct. (optimize_namespace): Set in_omp_workshare. (gfc_code_walker): Keep track of OMP PARALLEL and OMP WORKSHARE constructs. 2011-12-11 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/50690 * gfortran.dg/gomp/workshare2.f90: New test. * gfortran.dg/gomp/workshare3.f90: New test. From-SVN: r182208
2011-11-04frontend-passes.c (cfe_register_funcs): Return early in the case of an ↵Mikael Morin1-3/+4
inline intrinsic function. * frontend-passes.c (cfe_register_funcs): Return early in the case of an inline intrinsic function. (optimize_binop_array_assignment): Skip optimization in the case of an inline intrinsic function. From-SVN: r180911
2011-10-16frontend-passes.c (current_ns): Make static.Thomas Koenig1-2/+15
2011-10-16 Thomas Koenig <tkoenig@gcc.gnu.org> * frontend-passes.c (current_ns): Make static. (create_var): Note parent of newly created namespace. (optimize_namespace): Don't wak sibling namespaces if they are EXEC_BLOCK because this is handled... (gfc_code_walker): ... here. Also walk ASSOCIATE lists. From-SVN: r180063
2011-10-10re PR fortran/50564 (Front-end optimization - ICE with FORALL)Thomas Koenig1-0/+17
2011-10-10 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/50564 * frontend-passes (forall_level): New variable. (cfe_register_funcs): Don't register functions if we are within a forall loop. (optimize_namespace): Set forall_level to 0 before entry. (gfc_code_walker): Increase/decrease forall_level. 2011-10-10 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/50564 * gfortran.dg/forall_15.f90: New test case. From-SVN: r179770
2011-09-11re PR fortran/50327 (Front-end optimization generates wrong code for BLAS's ↵Thomas Koenig1-0/+80
srotmg) 2011-09-11 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/50327 * frontend-passes.c (dummy_expr_callback): New function. (convert_do_while): New function. (optimize_namespace): Call code walker to convert do while loops. 2011-09-11 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/50327 * gfortran.dg/do_while_1.f90: New test. From-SVN: r178768
2011-09-08re PR fortran/44646 ([F08] Implement DO CONCURRENT)Tobias Burnus1-0/+1
gcc/fortran/ 2011-09-08 Tobias Burnus <burnus@net-b.de> PR fortran/44646 * decl.c (gfc_match_entry, gfc_match_end): Handle * COMP_DO_CONCURRENT. * dump-parse-tree.c (show_code_node): Handle EXEC_DO_CONCURRENT. * gfortran.h (gfc_exec_op): Add EXEC_DO_CONCURRENT. * match.c (gfc_match_critical, match_exit_cycle, * gfc_match_stopcode, lock_unlock_statement, sync_statement, gfc_match_allocate, gfc_match_deallocate, gfc_match_return): Add DO CONCURRENT diagnostic. (gfc_match_do): Match DO CONCURRENT. (match_derived_type_spec, match_type_spec, gfc_free_forall_iterator, match_forall_iterator, match_forall_header, match_simple_forall, gfc_match_forall): Move up in the file. * parse.c (check_do_closure, parse_do_block): Handle do * concurrent. * parse.h (gfc_compile_state): Add COMP_DO_CONCURRENT. * resolve.c (do_concurrent_flag): New global variable. (resolve_function, pure_subroutine, resolve_branch, gfc_resolve_blocks, resolve_code, resolve_types): Add do concurrent diagnostic. * st.c (gfc_free_statement): Handle EXEC_DO_CONCURRENT. * trans-stmt.c (gfc_trans_do_concurrent): New function. (gfc_trans_forall_1): Handle do concurrent. * trans-stmt.h (gfc_trans_do_concurrent): New function * prototype. * trans.c (trans_code): Call it. * frontend-passes.c (gfc_code_walker): Handle * EXEC_DO_CONCURRENT. gcc/testsuite/ 2011-09-08 Tobias Burnus <burnus@net-b.de> PR fortran/44646 * gfortran.dg/do_concurrent_1.f90: New. * gfortran.dg/do_concurrent_2.f90: New. From-SVN: r178677
2011-08-20re PR fortran/49638 ([OOP] length parameter is ignored when overriding type ↵Janus Weil1-1/+1
bound character functions with constant length.) 2011-08-20 Janus Weil <janus@gcc.gnu.org> PR fortran/49638 * dependency.c (gfc_dep_compare_expr): Add new result value "-3". (gfc_check_element_vs_section,gfc_check_element_vs_element): Handle result value "-3". * frontend-passes.c (optimize_comparison): Ditto. * interface.c (gfc_check_typebound_override): Ditto. 2011-08-20 Janus Weil <janus@gcc.gnu.org> PR fortran/49638 * gfortran.dg/typebound_override_1.f90: Modified. From-SVN: r177932
2011-08-02backport: re PR fortran/46752 (OpenMP - Seg fault for unallocated ↵Jakub Jelinek1-0/+1
allocatable array in firstprivate clause) Merge from gomp-3_1-branch branch: 2011-08-02 Jakub Jelinek <jakub@redhat.com> gcc/ * c-parser.c (enum c_parser_prec): New enum, moved from within c_parser_binary_expression. (c_parser_binary_expression): Add PREC argument. Stop parsing if operator has lower or equal precedence than PREC. (c_parser_conditional_expression, c_parser_omp_for_loop): Adjust callers. (c_parser_omp_atomic): Handle parsing OpenMP 3.1 atomics. Adjust c_finish_omp_atomic caller. (c_parser_omp_taskyield): New function. (c_parser_pragma): Handle PRAGMA_OMP_TASKYIELD. (c_parser_omp_clause_name): Handle final and mergeable clauses. (c_parser_omp_clause_final, c_parser_omp_clause_mergeable): New functions. (c_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_FINAL and PRAGMA_OMP_CLAUSE_MERGEABLE. (OMP_TASK_CLAUSE_MASK): Allow final and mergeable clauses. (c_parser_omp_clause_reduction): Handle min and max. * c-typeck.c (c_finish_omp_clauses): Don't complain about const qualified predetermined vars in firstprivate clause. andle OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. Handle MIN_EXPR and MAX_EXPR. * tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. (dump_generic_node): Handle OMP_ATOMIC_READ, OMP_ATOMIC_CAPTURE_OLD and OMP_ATOMIC_CAPTURE_NEW. * tree.c (omp_clause_num_ops): Add OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. (omp_clause_code_name): Likewise. (walk_tree_1): Handle OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. * tree.h (enum omp_clause_code): Add OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. (OMP_CLAUSE_FINAL_EXPR): Define. * omp-low.c (scan_sharing_clauses): Handle OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. (expand_task_call): Likewise. (expand_omp_atomic_load, expand_omp_atomic_store): New functions. (expand_omp_atomic_fetch_op): Handle cases where old or new value is needed afterwards. (expand_omp_atomic): Call expand_omp_atomic_load resp. expand_omp_atomic_store. * gimplify.c (gimplify_omp_atomic, gimplify_expr): Handle OMP_ATOMIC_READ, OMP_ATOMIC_CAPTURE_OLD and OMP_ATOMIC_CAPTURE_NEW. (gimplify_scan_omp_clauses, gimplify_adjust_omp_clauses): Handle OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. * tree-nested.c (convert_nonlocal_omp_clauses, convert_local_omp_clauses): Likewise. * tree.def (OMP_ATOMIC_READ, OMP_ATOMIC_CAPTURE_OLD, OMP_ATOMIC_CAPTURE_NEW): New. * gimple.h (GF_OMP_ATOMIC_NEED_VALUE): New. (gimple_omp_atomic_need_value_p, gimple_omp_atomic_set_need_value): New inlines. * omp-builtins.def (BUILT_IN_GOMP_TASKYIELD): New builtin. * doc/generic.texi: Mention OMP_CLAUSE_COLLAPSE, OMP_CLAUSE_UNTIED, OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. gcc/c-family/ * c-common.h (c_finish_omp_atomic): Adjust prototype. (c_finish_omp_taskyield): New prototype. * c-omp.c (c_finish_omp_atomic): Add OPCODE, V, LHS1 and RHS1 arguments. Handle OMP_ATOMIC_READ, OMP_ATOMIC_CAPTURE_OLD and OMP_ATOMIC_CAPTURE_NEW in addition to OMP_ATOMIC. If LHS1 or RHS1 have side-effects, evaluate those too in the right spot, if it is a decl and LHS is also a decl, error out if they aren't the same. (c_finish_omp_taskyield): New function. * c-cppbuiltin.c (c_cpp_builtins): Change _OPENMP to 201107. * c-pragma.c (omp_pragmas): Add taskyield. * c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_TASKYIELD. (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_FINAL and PRAGMA_OMP_CLAUSE_MERGEABLE. gcc/cp/ * cp-tree.h (finish_omp_atomic): Adjust prototype. (cxx_omp_const_qual_no_mutable): New prototype. (finish_omp_taskyield): New prototype. * parser.c (cp_parser_omp_atomic): (cp_parser_omp_atomic): Handle parsing OpenMP 3.1 atomics. Adjust finish_omp_atomic caller. (cp_parser_omp_clause_name): Handle final and mergeable clauses. (cp_parser_omp_clause_final, cp_parser_omp_clause_mergeable): New functions. (cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_FINAL and PRAGMA_OMP_CLAUSE_MERGEABLE. (OMP_TASK_CLAUSE_MASK): Allow final and mergeable clauses. (cp_parser_omp_taskyield): New function. (cp_parser_pragma): Handle PRAGMA_OMP_TASKYIELD. (cp_parser_omp_clause_reduction): Handle min and max. * pt.c (tsubst_expr) <case OMP_ATOMIC>: Handle OpenMP 3.1 atomics. (tsubst_omp_clauses): Handle OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. * semantics.c (finish_omp_atomic): Add OPCODE, V, LHS1 and RHS1 arguments. Handle OpenMP 3.1 atomics. Adjust c_finish_omp_atomic caller. (finish_omp_clauses): Don't complain about const qualified predetermined vars and static data members in firstprivate clause. Handle OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. Handle MIN_EXPR and MAX_EXPR. (finish_omp_taskyield): New function. * cp-gimplify.c (cxx_omp_const_qual_no_mutable): New function. (cxx_omp_predetermined_sharing): Use it. gcc/fortran/ PR fortran/46752 * cpp.c (cpp_define_builtins): Change _OPENMP to 201107. * openmp.c (gfc_free_omp_clauses): Free also final_expr. (OMP_CLAUSE_FINAL, OMP_CLAUSE_MERGEABLE): Define. (gfc_match_omp_clauses): Handle parsing final and mergeable clauses. (OMP_TASK_CLAUSES): Allow final and mergeable clauses. (gfc_match_omp_taskyield): New function. (resolve_omp_clauses): Resolve final clause. Allow POINTERs and Cray pointers in clauses other than REDUCTION. (gfc_match_omp_atomic): Match optional read/write/update/capture keywords after !$omp atomic. (resolve_omp_atomic): Handle all OpenMP 3.1 atomic forms. * dump-parse-tree.c (show_omp_node): Handle EXEC_OMP_TASKYIELD, print final and mergeable clauses. (show_code_node): Handle EXEC_OMP_TASKYIELD. * trans-openmp.c (gfc_trans_omp_clauses): Handle final and mergeable clauses. (gfc_trans_omp_taskyield): New function. (gfc_trans_omp_directive): Handle EXEC_OMP_TASKYIELD. (gfc_trans_omp_atomic): Handle all OpenMP 3.1 atomic forms. (gfc_omp_clause_copy_ctor): Handle non-allocated allocatable. (gfc_omp_predetermined_sharing): Adjust comment. * gfortran.h (gfc_statement): Add ST_OMP_TASKYIELD and ST_OMP_END_ATOMIC. (gfc_omp_clauses): Add final_expr and mergeable fields. (gfc_exec_op): Add EXEC_OMP_TASKYIELD. (gfc_omp_atomic_op): New enum typedef. (struct gfc_code): Add ext.omp_atomic. * trans.c (trans_code): Handle EXEC_OMP_TASKYIELD. * frontend-passes.c (gfc_code_walker): Also walk final_expr. * resolve.c (gfc_resolve_blocks, resolve_code): Handle EXEC_OMP_TASKYIELD. * st.c (gfc_free_statement): Likewise. * match.h (gfc_match_omp_taskyield): New prototype. * parse.c (decode_omp_directive): Handle taskyield directive. Handle !$omp end atomic. (case_executable): Add ST_OMP_TASKYIELD case. (gfc_ascii_statement): Handle ST_OMP_TASKYIELD. (parse_omp_atomic): Return gfc_statement instead of void. For !$omp atomic capture parse two assignments instead of just one and require !$omp end atomic afterwards, for other !$omp atomic forms just allow !$omp end atomic at the end. (parse_omp_structured_block, parse_executable): Adjust parse_omp_atomic callers. 2011-08-02 Tobias Burnus <burnus@net-b.de> * intrinsic.c (OMP_LIB): Updated openmp_version's value to 201107. * gfortran.texi (OpenMP): Update ref to OpenMP 3.1. * intrinsic.texi (OpenMP Modules): Update ref to OpenMP 3.1; remove deleted omp_integer_kind and omp_logical_kind constants. gcc/testsuite/ PR fortran/46752 * gcc.dg/gomp/atomic-5.c: Adjust expected diagnostics. * gcc.dg/gomp/atomic-15.c: New test. * g++.dg/gomp/atomic-5.C: Adjust expected diagnostics. * g++.dg/gomp/atomic-15.C: New test. * g++.dg/gomp/private-1.C: New test. * g++.dg/gomp/sharing-2.C: New test. * gfortran.dg/gomp/crayptr1.f90: Don't expect error about Cray pointer in FIRSTPRIVATE/LASTPRIVATE. * gfortran.dg/gomp/omp_atomic2.f90: New test. libgomp/ PR fortran/42041 PR fortran/46752 * omp.h.in (omp_in_final): New prototype. * omp_lib.f90.in (omp_in_final): New interface. (omp_integer_kind, omp_logical_kind): Remove and replace all its uses in the module with 4. (openmp_version): Change to 201107. * omp_lib.h.in (omp_sched_static, omp_sched_dynamic, omp_sched_guided, omp_sched_auto): Use omp_sched_kind kind for the parameters. (omp_in_final): New external. (openmp_version): Change to 201107. * task.c (omp_in_final): New function. (gomp_init_task): Initialize final_task. (GOMP_task): Remove unused attribute from flags. Handle final tasks. (GOMP_taskyield): New function. (omp_in_final): Return true if if (false) or final (true) task or descendant of final (true). * fortran.c (omp_in_final_): New function. * libgomp.map (OMP_3.1): Export omp_in_final and omp_in_final_. (GOMP_3.0): Export GOMP_taskyield. * env.c (gomp_nthreads_var_list, gomp_nthreads_var_list_len): New variables. (parse_unsigned_long_list): New function. (initialize_env): Use it for OMP_NUM_THREADS. Call parse_boolean with "OMP_PROC_BIND". If OMP_PROC_BIND=true, call gomp_init_affinity even if parse_affinity returned false. * config/linux/affinity.c (gomp_init_affinity): Handle gomp_cpu_affinity_len == 0. * libgomp_g.h (GOMP_taskyield): New prototype. * libgomp.h (struct gomp_task): Add final_task field. (gomp_nthreads_var_list, gomp_nthreads_var_list_len): New externs. * team.c (gomp_team_start): Override new task's nthreads_var icv if list form OMP_NUM_THREADS has been used and it has value for the new nesting level. * testsuite/libgomp.c/atomic-11.c: New test. * testsuite/libgomp.c/atomic-12.c: New test. * testsuite/libgomp.c/atomic-13.c: New test. * testsuite/libgomp.c/atomic-14.c: New test. * testsuite/libgomp.c/reduction-6.c: New test. * testsuite/libgomp.c/task-5.c: New test. * testsuite/libgomp.c++/atomic-2.C: New test. * testsuite/libgomp.c++/atomic-3.C: New test. * testsuite/libgomp.c++/atomic-4.C: New test. * testsuite/libgomp.c++/atomic-5.C: New test. * testsuite/libgomp.c++/atomic-6.C: New test. * testsuite/libgomp.c++/atomic-7.C: New test. * testsuite/libgomp.c++/atomic-8.C: New test. * testsuite/libgomp.c++/atomic-9.C: New test. * testsuite/libgomp.c++/task-8.C: New test. * testsuite/libgomp.c++/reduction-4.C: New test. * testsuite/libgomp.fortran/allocatable7.f90: New test. * testsuite/libgomp.fortran/allocatable8.f90: New test. * testsuite/libgomp.fortran/crayptr3.f90: New test. * testsuite/libgomp.fortran/omp_atomic3.f90: New test. * testsuite/libgomp.fortran/omp_atomic4.f90: New test. * testsuite/libgomp.fortran/pointer1.f90: New test. * testsuite/libgomp.fortran/pointer2.f90: New test. * testsuite/libgomp.fortran/task4.f90: New test. 2011-08-02 Tobias Burnus <burnus@net-b.de> * libgomp.texi: Update OpenMP spec references to 3.1. (omp_in_final,OMP_PROC_BIND): New sections. (OMP_NUM_THREADS): Document that the value can be now a list. (GOMP_STACKSIZE,GOMP_CPU_AFFINITY): Update @ref. From-SVN: r177194
2011-07-28re PR fortran/31067 (MINLOC should sometimes be inlined (gas_dyn is sooooo ↵Jakub Jelinek1-1/+56
sloooow)) PR fortran/31067 * frontend-passes.c (optimize_minmaxloc): New function. (optimize_expr): Call it. * gfortran.dg/maxloc_2.f90: New test. * gfortran.dg/maxloc_3.f90: New test. * gfortran.dg/minloc_1.f90: New test. * gfortran.dg/minloc_2.f90: New test. * gfortran.dg/minloc_3.f90: New test. * gfortran.dg/minmaxloc_7.f90: New test. From-SVN: r176897
2011-06-13frontend-passes.c (remove_trim): New function.Thomas Koenig1-43/+36
2011-06-13 Thomas Koenig <tkoenig@gcc.gnu.org> * frontend-passes.c (remove_trim): New function. (optimize_assignment): Use it. (optimize_comparison): Likewise. Return correct status for previous change. 2011-06-13 Thomas Koenig <tkoenig@gcc.gnu.org> * gfortran.dg/trim_optimize_8.f90: New test case. From-SVN: r174983
2011-06-11frontend-passes.c (optimize_assignment): Follow chains of concatenation ↵Thomas Koenig1-0/+8
operators to the end for removing trailing TRIMS... 2011-05-11 Thomas Koenig <tkoenig@gcc.gnu.org> * frontend-passes.c (optimize_assignment): Follow chains of concatenation operators to the end for removing trailing TRIMS for assignments. 2011-05-11 Thomas Koenig <tkoenig@gcc.gnu.org> * gfortran.dg/trim_optimize_7.f90: New test. From-SVN: r174944
2011-06-08re PR fortran/18918 (Eventually support Fortran 2008's coarrays [co-arrays])Tobias Burnus1-0/+1
2011-06-08 Tobias Burnus <burnus@net-b.de> PR fortran/18918 * gfortran.h (gfc_statement): Add ST_LOCK and ST_UNLOCK. (gfc_exec_op): Add EXEC_LOCK and EXEC_UNLOCK. (gfc_code): Add expr4. * match.h (gfc_match_lock, gfc_match_unlock): New prototypes. * match.c (gfc_match_lock, gfc_match_unlock, lock_unlock_statement): New functions. (sync_statement): Bug fix, avoiding double freeing. (gfc_match_if): Handle LOCK/UNLOCK statement. * parse.c (decode_statement, next_statement, gfc_ascii_statement): Ditto. * st.c (gfc_free_statement): Handle LOCK and UNLOCK. * resolve.c (resolve_lock_unlock): New function. (resolve_code): Call it. * dump-parse-tree.c (show_code_node): Handle LOCK/UNLOCK. * frontend-passes.c (gfc_code_walker): Optimize gfc_code's expr4. 2011-06-08 Tobias Burnus <burnus@net-b.de> PR fortran/18918 * gfortran.dg/coarray_lock_1.f90: New. * gfortran.dg/coarray_lock_2.f90: New. From-SVN: r174796
2011-05-22frontend-passes.c (cfe_register_funcs): Also register character functions if ↵Thomas Koenig1-9/+8
their charlens are known and constant. 2011-05-22 Thomas Koenig <tkoenig@gcc.gnu.org> * frontend-passes.c (cfe_register_funcs): Also register character functions if their charlens are known and constant. Also register allocatable functions. 2011-05-22 Thomas Koenig <tkoenig@gcc.gnu.org> * gfortran.dg/function_optimize_8.f90: New test case. From-SVN: r174027
2011-05-14re PR fortran/22572 (Double occurrence of matmul intrinsic not optimised)Thomas Koenig1-18/+34
2011-05-14 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/22572 * frontend-passes.c (cfe_register_funcs): Also register functions for potential elimination if the rank is > 0, the shape is unknown and reallocate on assignment is active. (create_var): For rank > 0 functions with unknown shape, create an allocatable temporary. 2011-05-14 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/22572 * function_optimize_7.f90: New test case. From-SVN: r173752
2011-04-26frontend-passes.c (inserted_block): New variable.Thomas Koenig1-5/+35
2011-04-26 Thomas Koenig <tkoenig@gcc.gnu.org> * frontend-passes.c (inserted_block): New variable. (changed_statement): Likewise. (create_var): Encase statement to be operated on in a BLOCK. Adjust code insertion for BLOCK. (cfe_code): Set inserted_block and changed_statement to NULL. From-SVN: r172983
2011-04-21re PR fortran/48405 (Handle expressions in DO loops for front-end optimization)Thomas Koenig1-111/+111
2011-04-21 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/48405 * frontend_passes (cfe_register_funcs): Remove workaround for DO loops. (gfc_code_walker): Make sure the pointer to the current statement doen't change when other statements are inserted. 2011-04-21 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/48405 * gfortran.dg/function_optimize_6.f90: New test. From-SVN: r172838
2011-04-19Use XDELETEVEC instead of freeJanne Blomqvist1-3/+1
From-SVN: r172729
2011-04-18convert each use of gfc_free (p) to free (p)Jim Meyering1-9/+9
Do that by running this command: perl -pi -e 's/\bgfc_free ?\(/free (/' \ $(git grep -El '\bgfc_free ?\(') which also corrects the few uses that lacked a space between the function name and the open parenthesis. Manually undo the change to the function definition itself and its prototype. They'll be removed next. * array.c (gfc_free_array_spec, gfc_set_array_spec): s/gfc_free/free/ * constructor.c (node_free): Likewise. * cpp.c (dump_queued_macros): Likewise. * data.c (gfc_assign_data_value): Likewise. * decl.c (free_variable, free_value, gfc_free_data): Likewise. (gfc_free_data_all, match_old_style_init): Likewise. (gfc_set_constant_character_len, gfc_free_enum_history, NUM_DECL): Likewise. (gfc_match_modproc): Likewise. * dependency.c (check_section_vs_section): Likewise. * error.c (gfc_pop_error, gfc_free_error): Likewise. * expr.c (free_expr0, gfc_free_expr, gfc_free_actual_arglist): Likewise. (gfc_free_ref_list, gfc_replace_expr, gfc_copy_ref): Likewise. (find_substring_ref, gfc_simplify_expr, gfc_check_assign_symbol): Likewise. * frontend-passes.c (gfc_run_passes, cfe_expr_0): Likewise. (strip_function_call, optimize_comparison): Likewise. * interface.c (gfc_free_interface, arginfo, check_interface0): Likewise. (CHECK_OS_COMPARISON, gfc_extend_assign, gfc_free_formal_arglist): Likewise. * intrinsic.c (gfc_intrinsic_done_1, gfc_convert_type_warn): Likewise. (gfc_convert_chartype): Likewise. * io.c (gfc_free_open, compare_to_allowed_values, gfc_free_close): Likewise. (gfc_free_filepos, gfc_free_dt, gfc_free_inquire): Likewise. * match.c (gfc_free_iterator, gfc_match_associate): Likewise. (gfc_free_alloc_list, gfc_free_namelist, gfc_free_equiv_until): Likewise. (free_case, gfc_free_forall_iterator): Likewise. * misc.c: Likewise. * module.c (free_pi_tree, resolve_fixups, free_rename): Likewise. (free_true_name, peek_atom, mio_allocated_wide_string): Likewise. (mio_pool_string, mio_internal_string, mio_gmp_integer): Likewise. (mio_gmp_real, mio_expr, mio_typebound_proc): Likewise. (mio_full_typebound_tree, skip_list, load_equiv): Likewise. (free_written_common, gfc_use_module, gfc_free_use_stmts): Likewise. * openmp.c (gfc_free_omp_clauses): Likewise. * options.c (gfc_post_options): Likewise. * parse.c (select_type_pop, parse_omp_structured_block): Likewise. * primary.c (gfc_free_structure_ctor_component): Likewise. * resolve.c (resolve_structure_cons, check_host_association): Likewise. (gfc_resolve_forall, resolve_equivalence): Likewise. * scanner.c (gfc_scanner_done_1, gfc_release_include_path): Likewise. (gfc_define_undef_line, preprocessor_line, include_line): Likewise. (load_file, gfc_read_orig_filename): Likewise. * simplify.c (simplify_transformation_to_array): Likewise. (gfc_simplify_ibits, simplify_shift, gfc_simplify_ishftc, STRING): Likewise. (gfc_simplify_compiler_options): Likewise. * st.c (gfc_free_statement, gfc_free_statements): Likewise. (gfc_free_association_list): Likewise. * symbol.c (free_components, gfc_free_st_label, free_st_labels): Likewise. (gfc_delete_symtree, gfc_free_symbol, gfc_undo_symbols): Likewise. (free_old_symbol, gfc_commit_symbols, free_tb_tree): Likewise. (free_common_tree, free_uop_tree, free_sym_tree): Likewise. (gfc_free_dt_list, gfc_free_equiv_infos, gfc_free_equiv_lists): Likewise. (gfc_free_finalizer, gfc_free_charlen, free_entry_list): Likewise. (gfc_free_namespace): Likewise. * trans-array.c (gfc_free_ss, gfc_trans_array_bound_check): Likewise. (gfc_conv_array_ref, gfc_conv_ss_startstride): Likewise. (gfc_trans_dummy_array_bias, gfc_conv_array_parameter): Likewise. * trans-common.c (get_init_field, create_common): Likewise. * trans-const.c (gfc_build_wide_string_const): Likewise. (gfc_conv_string_init): Likewise. * trans-decl.c (gfc_generate_function_code): Likewise. * trans-expr.c (gfc_conv_substring, gfc_free_interface_mapping): Likewise. (SCALAR_POINTER, gfc_conv_statement_function): Likewise. (gfc_trans_subarray_assign): Likewise. * trans-intrinsic.c (conv_generic_with_optional_char_arg): Likewise. * trans-io.c (gfc_trans_io_runtime_check, set_string): Likewise. (transfer_namelist_element, transfer_array_component): Likewise. * trans-openmp.c (gfc_trans_omp_array_reduction): Likewise. * trans-stmt.c (cleanup_forall_symtrees, gfc_trans_forall_1): Likewise. * trans.c (trans_runtime_error_vararg, gfc_restore_backend_locus): Likewise. From-SVN: r172666
2011-04-10Remove doubled up words.Mike Stump1-1/+1
From-SVN: r172247
2011-04-08re PR fortran/48448 (Implement -f(no-)frontend-optimization)Thomas Koenig1-1/+19
2011-04-08 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/48448 * gfortran.h (gfc_option_t): Add warn_function_elimination and flag_frontend_optimize. * lang.opt (Wfunction-elimination): Add. (ffrontend-optimize): Add. * invoke.texi: Add documentation for -Wfunction-elimination and -ffrontend-optimize. Add -faggressive-function-elimination to list of code generation options. * frontend-passes.c (gfc_run_passes): Run optimizations if flag_frontend_optimize is set. (warn_function_elimination): New function. (cfe_expr_0): Call it if requested to do so. * options.c (gfc_init_options): Initiate warn_function_elimination and flag_frontend_optimize. (gfc_post_options): Set flag_frontend_optimize if not specified by user, depending on the optimization level. (gfc_handle_option): Handle -Wfunction-elimination and -ffrontend-optimize. 2011-04-08 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/48448 * gfortran.dg/function_optimize_5.f90: New test. From-SVN: r172215
2011-04-04frontend-passes: (optimize_lexical_comparison): New function.Thomas Koenig1-7/+72
2010-04-04 Thomas Koenig <tkoenig@gcc.gnu.org> * frontend-passes: (optimize_lexical_comparison): New function. (optimize_expr): Call it. (optimize_comparison): Also handle lexical comparison functions. Return false instad of -2 for unequal comparison. 2010-04-04 Thomas Koenig <tkoenig@gcc.gnu.org> * gfortran.dg/character_comparison_8.f90: New test. From-SVN: r171953
2011-04-04re PR fortran/48412 (CP2K miscompiled due to some Fortran frontend pass)Thomas Koenig1-4/+4
2011-04-04 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/48412 * frontend-passes (cfe_expr_0): Reverse the order of going through the loops. 2011-04-04 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/48412 * function_optimize_4.f90: New test. From-SVN: r171952
2011-04-01re PR fortran/48352 (segfault in fortran/frontend-passes.c)Thomas Koenig1-0/+7
2011-04-01 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/48352 * frontend-passes (cfe_register_funcs): Don't register functions if they appear as iterators in DO loops. 2011-04-01 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/48352 * gfortran.dg/function_optimize_3.f90: New test. From-SVN: r171849
2011-03-29function_optimize_1.f90: Add -Warray-temporaries, check for corresponding ↵Thomas Koenig1-0/+2
warning. 2011-03-29 Thomas Koenig <tkoenig@gcc.gnu.org> * gfortran.dg/function_optimize_1.f90: Add -Warray-temporaries, check for corresponding warning. 2011-03-29 Thomas Koenig <tkoenig@gcc.gnu.org> * frontend-passes.c (create_var): Warn about creating an array temporary if requested. From-SVN: r171653
2011-03-27re PR fortran/47065 (Replace trim(a) by a(1:len_trim(a)))Thomas Koenig1-29/+38
2011-03-27 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/47065 * frontend-passes (optimize_trim): Also follow references, except when they are substring references or array references. 2011-03-27 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/47065 * gfortran.dg/trim_optimize_5.f90: New test. * gfortran.dg/trim_optimize_6.f90: New test. From-SVN: r171575
2011-03-21re PR fortran/22572 (Double occurrence of matmul intrinsic not optimised)Thomas Koenig1-0/+225
2010-03-21 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/22572 * gfortran.h (gfc_option_t) : Add flag_aggressive_function_elimination. (gfc_dep_compare_functions): Add prototype. * lang.opt: Add faggressive-function-elimination. * invoke.texi: Document -faggressive-function-elimination. * frontend_passes (expr_array): New static variable. (expr_size): Likewise. (expr_count): Likewise. (current_code): Likewise. (current_ns): Likewise. (gfc_run_passes): Allocate and free space for expressions. (cfe_register_funcs): New function. (create_var): New function. (cfc_expr_0): New function. (cfe_code): New function. (optimize_namespace): Invoke gfc_code_walker with cfe_code and cfe_expr_0. * dependency.c (gfc_dep_compare_functions): New function. (gfc_dep_compare_expr): Use it. * options.c (gfc_init_options): Handle flag_aggressive_function_elimination. (gfc_handle_option): Likewise. 2010-03-21 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/22572 * gfortran.dg/function_optimize_1.f90: New test. * gfortran.dg/function_optimize_2.f90: New test. From-SVN: r171207
2011-01-13re PR fortran/45848 ([OOP] ICE on invalid code in fortran/symbol.c:2410)Tobias Burnus1-1/+1
2011-01-13 Tobias Burnus <burnus@net-b.de> Mikael Morin <mikael@gcc.gnu.org> PR fortran/45848 PR fortran/47204 * gfortran.h (gfc_code): Move union ext's case_list into the struct block. * dump-parse-tree.c (show_code_node): Adapt by prefixing * case_list by "block.". * frontend-passes.c (gfc_code_walker): Ditto. * match.c (gfc_match_goto, gfc_match_call, gfc_match_case, gfc_match_type_is, gfc_match_class_is): Ditto. * resolve.c (resolve_select, resolve_select_type): Ditto. * st.c (gfc_free_statement): Ditto. * trans-stmt.c (gfc_trans_integer_select, * gfc_trans_logical_select, gfc_trans_character_select): Ditto. * parse.c (resolve_all_program_units): For error recovery, avoid segfault is proc_name is NULL. 2011-01-13 Tobias Burnus <burnus@net-b.de> Mikael Morin <mikael@gcc.gnu.org> PR fortran/45848 PR fortran/47204 * gfortran.dg/select_type_20.f90: New. * gfortran.dg/select_type_21.f90: New. Co-Authored-By: Mikael Morin <mikael@gcc.gnu.org> From-SVN: r168753
2010-12-31re PR fortran/47065 (Replace trim(a) by a(1:len_trim(a)))Thomas Koenig1-1/+104
2010-12-31 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/47065 * frontend-passes.c (count_arglist): Static variable to count the nesting of argument lists. (optimize_code): Set count_arglist to 1 if within a call statement, to 0 otherwise. (optimize_trim): New function. (optimize_expr): Adjust count_arglist. Call optimize_trim. 2010-12-31 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/47065 * gfortran.dg/trim_optimize_3.f90: New test. * gfortran.dg/trim_optimize_4.f90: New test. From-SVN: r168367
2010-12-29frontend-passes.c (gfc_code_walker): Handle expressions in EXEC_CALL, ↵Thomas Koenig1-0/+26
EXEC_ASSIGN_CALL and EXEC_CALL_PPC. 2010-12-29 Thomas Koenig <tkoenig@gcc.gnu.org> * frontend-passes.c (gfc_code_walker): Handle expressions in EXEC_CALL, EXEC_ASSIGN_CALL and EXEC_CALL_PPC. Separate cases in switch statements by blank lines. 2010-12-29 Thomas Koenig <tkoenig@gcc.gnu.org> * gfortran.dg/character_comparison_7.f90: New test. From-SVN: r168320
2010-10-30gfortran.h (gfc_option_t): Replace dump_parse_tree by dump_fortran_original ↵Thomas Koenig1-1/+5
and add dump_fortran_optimized. 2010-10-30 Thomas Koenig <tkoenig@gcc.gnu.org> * gfortran.h (gfc_option_t): Replace dump_parse_tree by dump_fortran_original and add dump_fortran_optimized. * lang.opt: Add fdump-fortran-original and fdump-fortran-optimized. Document that fdump-parse-tree is deprecated. * gfortran.texi: Add -fdump-fortran-original and -fdump-fortran-optimized. -fdump-parse-tree is deprecated. * frontend-passes.c (gfc_run_passes): If optimizing and if gfc_option.dump_fortran_optimized is set, dump the parse tree after optimization. * parse.c: Rename gfc_option.dump_parse_tree to gfc_option.dump_fortran_original. * options.c (gfc_init_options): Rename gfc_option.dump_parse_tree to gfc_option.dump_fortran_original and handle gfc_option.dump_fortran_optimize. (gfc_post_options): Rename gfc_option.dump_parse_tree to gfc_option.dump_fortran_original. (gfc_handle_option): Rename OPT_fdump_parse_tree to OPT_fdump_fortran_original and gfc_option.dump_parse_tree to gfc_option.dump_fortran_original. Handle OPT_fdump_fortran_optimized. From-SVN: r166091
2010-10-10frontend-passes.c: Include opts.h.Thomas Koenig1-20/+105
2010-10-09 Thomas Koenig <tkoenig@gcc.gnu.org> * frontend-passes.c: Include opts.h. (optimize_comparison): Renamed from optimize_equality. Change second argument to operation to be compared. Use flag_finite_math_only to avoid comparing REAL and COMPLEX only when NANs are honored. Simplify comparing of string concatenations where left or right operands are equal. Simplify all comparison operations, based on the result of gfc_dep_compare_expr. * dependency.c: Include arith.h. (gfc_are_identical_variables): Volatile variables should not compare equal to themselves. (gfc_dep_compare_expr): Handle string constants and string concatenations. 2010-10-09 Thomas Koenig <tkoenig@gcc.gnu.org> * gfortran.dg/character_comparison_4.f90: New test. * gfortran.dg/character_comparison_5.f90: New test. * gfortran.dg/character_comparison_6.f90: New test. From-SVN: r165248
2010-09-23re PR fortran/45744 (ICE with -O1 in gfc_conv_expr_op, at ↵Thomas Koenig1-2/+7
fortran/trans-expr.c:1366) 2010-09-23 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/45744 * frontend-passes.c (optimize_binop_array_assignment): Only re-use lhs as intermediate storage if kind and type parameters match. 2010-09-23 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/45744 * gfortran.dg/dependency_36.f90: New test. From-SVN: r164570
2010-09-18frontend-passes.c (gfc_expr_walker): Also handle EXPR_SUBSTRING.Thomas Koenig1-0/+1
2010-09-19 Thomas Koenig <tkoenig@gcc.gnu.org> * frontend-passes.c (gfc_expr_walker): Also handle EXPR_SUBSTRING. From-SVN: r164404
2010-09-18frontend-passes.c (gfc_expr_walker): Handle constructors and references.Thomas Koenig1-0/+58
2010-09-17 Thomas Koenig <tkoenig@gcc.gnu.org> * frontend-passes.c (gfc_expr_walker): Handle constructors and references. From-SVN: r164403
2010-09-16gfortran.h (walk_code_fn_t, [...]): New types.Jakub Jelinek1-251/+266
* gfortran.h (walk_code_fn_t, walk_expr_fn_t): New types. (gfc_expr_walker, gfc_code_walker): New prototypes. * frontend-passes.c (gfc_expr_walker, gfc_code_walker): New functions. (WALK_SUBEXPR, WALK_SUBEXPR_TAIL, WALK_SUBCODE): Define. (optimize_namespace): Use gfc_code_walker. (optimize_code, optimize_expr): Rewritten as gfc_code_walker hooks. (optimize_expr_0, optimize_code_node, optimize_actual_arglist): Removed. (optimize_assignment): Don't call optimize_expr_0. From-SVN: r164342
2010-09-08* frontend-passes.c (optimize_code_node): Walk block chain by default.Jakub Jelinek1-1/+5
From-SVN: r164014
2010-09-06re PR fortran/36931 (unneeded temporary for array intrinsic binop scalar)Thomas Koenig1-0/+78
2010-09-06 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/36931 * frontend-passes.c (optimize_binop_array_assignment): New function. (optimize_assignment): Call it. 2010-09-06 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/36931 * gfortran.dg/dependency_35.f90: New test. From-SVN: r163934
2010-09-03dump_parse_tree (gfc_run_passes): Call optimize_namespace instead of ↵Thomas Koenig1-2/+14
optimize_code. 2010-09-03 Thomas Koenig <tkoenig@gcc.gnu.org> * dump_parse_tree (gfc_run_passes): Call optimize_namespace instead of optimize_code. (optimize_namespace): New function. 2010-09-03 Thomas Koenig <tkoenig@gcc.gnu.org> * gfortran.dg/trim_optimize_2.f90: New test. From-SVN: r163846
2010-08-23re PR fortran/45380 (ICE in gfc_conv_intrinsic_any_all at -O{n>0})Mikael Morin1-0/+7
2010-08-23 Mikael Morin <mikael@gcc.gnu.org> PR fortran/45380 * frontend-passes.c (optimize_equality): Don't optimize array equality From-SVN: r163484
2010-08-02re PR fortran/36854 ([meta-bug] fortran front-end optimization)Thomas Koenig1-5/+5
2010-08-02 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/36854 * dependency.h: Add prototype for gfc_are_identical_variables. * frontend-passes.c: Include depencency.h. (optimimize_equality): Use gfc_are_identical_variables. * dependency.c (identical_array_ref): New function. (gfc_are_identical_variables): New function. (gfc_deb_compare_expr): Use gfc_are_identical_variables. * dependency.c (gfc_check_section_vs_section). Rename gfc_ prefix from statc function. (check_section_vs_section): Change arguments to gfc_array_ref, adjust function body accordingly. 2010-08-02 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/36854 * gfortran.dg/character_comparison_2.f90: New test. * gfortran.dg/character_comparison_3.f90: New test. * gfortran.dg/dependency_28.f90: New test. From-SVN: r162824
2010-07-25re PR fortran/40628 (Assignment using "= trim(string)": Optimize "trim" away)Thomas Koenig1-0/+435
2010-07-25 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/40628 * Make-lang.in: Add fortran/frontend-passes.o. * gfortran.h: Add prototype for gfc_run_passes. * resolve.c (gfc_resolve): Call gfc_run_passes. * frontend-passes.c: New file. 2010-07-25 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/40628 * trim_optimize_1.f90: New test. * character_comparision_1.f90: New test. From-SVN: r162519