Commit Graph

18 Commits

Author SHA1 Message Date
Richard Biener 434fa90395 genmatch.c (replace_id): Copy expr_type.
2015-02-09  Richard Biener  <rguenther@suse.de>

	* genmatch.c (replace_id): Copy expr_type.

From-SVN: r220541
2015-02-09 13:43:17 +00:00
Jakub Jelinek 5624e564d2 Update copyright years.
From-SVN: r219188
2015-01-05 13:33:28 +01:00
Richard Biener d0af2c6589 genmatch.c (parser::parser): Initialize capture_ids.
2014-12-16  Richard Biener  <rguenther@suse.de>

	* genmatch.c (parser::parser): Initialize capture_ids.
	(parser::parse_pattern): Properly allocate capture_ids before
	using them.  Set capture_ids to zero when its lifetime is
	supposed to finish.
	(parser::parse_simplify): Allocate capture_ids only if
	required.

From-SVN: r218786
2014-12-16 18:24:55 +00:00
Richard Biener 1c9b044857 genmatch.c: Include hash-set.h.
2014-12-02  Richard Biener  <rguenther@suse.de>
	Prathamesh Kulkarni  <bilbotheelffriend@gmail.com>

	* genmatch.c: Include hash-set.h.
	(fatal_at): Add source_location overload.
	(parser::record_operlist): New method.
	(parser::push_simplify): Likewise.
	(parser::oper_lists_set): New member.
	(parser::oper_lists): Likewise.
	(parser::parse_operation): Record seen operator list references.
	(parser::parse_c_expr): Likewise.
	(parser::parse_simplify): Init oper_lists_set and oper_lists
	and use push_simplify.
	(parser::parser): Init oper_lists_set and oper_lists.

Co-Authored-By: Prathamesh Kulkarni <bilbotheelffriend@gmail.com>

From-SVN: r218261
2014-12-02 09:30:15 +00:00
Richard Biener 7e015fcefe re PR tree-optimization/64084 (match-and-simplify prefers complex matches)
2014-11-28  Richard Biener  <rguenther@suse.de>

	PR middle-end/64084
	* genmatch.c (dt_node::gen_kids_1): New function, split out
	from dt_node::gen_kids.
	(decision_tree::cmp_node): DT_TRUE are generally not equal.
	(decision_tree::find_node): Treat DT_TRUE as barrier for
	node CSE on the same level.
	(dt_node::append_node): Do not keep DT_TRUE last.
	(dt_node::gen_kids): Emit code after each DT_TRUE node seen.

	* gcc.dg/tree-ssa/ssa-ccp-34.c: New testcase.
	* gcc.dg/tree-ssa/forwprop-31.c: Likewise.

From-SVN: r218141
2014-11-28 08:57:43 +00:00
Richard Biener 1023001708 genmatch.c (add_operator): Allow CONSTRUCTOR.
2014-11-14  Richard Biener  <rguenther@suse.de>

	* genmatch.c (add_operator): Allow CONSTRUCTOR.
	(dt_node::gen_kids): Handle CONSTRUCTOR not as GENERIC.
	(parser::parse_op): Allow to iterate over predicates.

From-SVN: r217541
2014-11-14 08:37:41 +00:00
Richard Biener 3f341ee716 genmatch.c (dt_node::gen_kids): Fix placement of break statement.
2014-11-13  Richard Biener  <rguenther@suse.de>

	* genmatch.c (dt_node::gen_kids): Fix placement of break statement.

From-SVN: r217487
2014-11-13 13:41:11 +00:00
Richard Biener 72eb311da1 [multiple changes]
2014-11-12  Richard Biener  <rguenther@suse.de>

	Merge from match-and-simplify branch
	2014-11-04  Prathamesh Kulkarni  <bilbotheelffriend@gmail.com>

	* genmatch.c (user_id): Add new member is_oper_list.
	(user_id::user_id): Add new default argument.
	(parser::parse_operator_list): New function.
	(parser::parse_for): Allow operator-list.
	(parser::parse_pattern): Call parser::parse_operator_list.
	(parser::parse_operation): Reject operator-list.
	* match-builtin.pd: Define operator lists POWs, CBRTs and SQRTs.

	2014-10-31  Prathamesh Kulkarni  <bilbotheelffriend@gmail.com>

	* genmatch.c (parser::parse_c_expr): Mark user-defined ops as used.

	2014-10-30  Prathamesh Kulkarni  <bilbotheelffriend@gmail.com>

	* genmatch.c (parser::parse_op): Check if predicate is used in
	result operand.

	2014-10-29  Prathamesh Kulkarni  <bilbotheelffriend@gmail.com>

	* genmatch.c (parser::parse_for): Make sure to have a valid
	token to report errors at.

	2014-10-28  Prathamesh Kulkarni  <bilbotheelffriend@gmail.com>

	* genmatch.c (parser): Add new member parsing_match_operand.
	(parser::parse_operation): Check for conditional convert in result
	operand.
	(parser::parse_expr): Check for commutative operator in result operand.
	Check for :type in match operand.
	(parser::parse_simplify): Set/unset parsing_match_operand.
	(parser::parser): Initialize parsing_match_operand.

	2014-10-28  Richard Biener  <rguenther@suse.de>

	* genmatch.c (parser::parse_for): Properly check for already
	defined operators.

	2014-10-28  Prathamesh Kulkarni  <bilbotheelffriend@gmail.com>

	* genmatch.c (error_cb): Adjust for printing warnings.
	(warning_at): New function.
	(user_id): Add new member used.
	(get_operator): Mark user_id as used.
	(parse_for): Warn for unused operators.

From-SVN: r217422
2014-11-12 14:29:14 +00:00
Richard Biener 47b25362bc genmatch.c (::gen_transform): Add capture_info and expand_compares arguments.
2014-11-12  Richard Biener  <rguenther@suse.de>

	* genmatch.c (::gen_transform): Add capture_info and
	expand_compares arguments.
	(struct expr): Add is_generic flag.
	(lower_cond): New functions lowering [VEC_]COND_EXPR
	conditions to a GENERIC and a GIMPLE variant.
	(lower): Call lower_cond.
	(cmp_operand): Also compare the is_generic flag.
	(capture_info::cinfo): Add cond_expr_cond_p flag.
	(capture_info::capture_info): Pass down whether the
	expression argument is a COND_EXPR condition.
	(capture_info::walk_match): Likewise, mark captures
	capturing COND_EXPR conditions with cond_expr_cond_p.
	(expr::gen_transform): Pass down whether we need to
	expand compares from COND_EXPR conditions.
	(capture::gen_transform): Expand compares substituted
	from COND_EXPR conditions into non-COND_EXPR conditions.
	(dt_operand::gen_gimple_expr): Handle explicitely marked
	GENERIC expressions as generic.
	(dt_simplify::gen): Pass whether we need to expand
	conditions to gen_transform.  Handle capture results
	which are from COND_EXPR conditions.
	(main): Pass gimple flag down to lower.

From-SVN: r217416
2014-11-12 12:49:14 +00:00
Richard Biener 6a3cbe9092 genmatch.c (capture_info::capture_info): Add missing COND_EXPR handling.
2014-11-12  Richard Biener  <rguenther@suse.de>

	* genmatch.c (capture_info::capture_info): Add missing
	COND_EXPR handling.
	(capture_info::walk_match): Fix COND_EXPR handling.
	(capture_info::walk_result): Likewise.

From-SVN: r217414
2014-11-12 11:59:40 +00:00
Richard Biener e7d1000cd7 re PR middle-end/63819 (Cannot build compiler with --enable-gather-detailed-mem-stats (error: default argument given for parameter 5 of ‘void* ggc_internal_cleared_alloc))
2014-11-12  Richard Biener  <rguenther@suse.de>

	PR bootstrap/63819
	* hash-table.h: Include ggc.h also for generator programs.
	* genmatch.c (ggc_internal_cleared_alloc): Properly define
	using MEM_STAT_DECL instead of CXX_MEM_STAT_INFO.

From-SVN: r217410
2014-11-12 10:12:47 +00:00
Richard Biener 1e51d0a29d match.pd: Add patterns convering two conversions in a row from fold-const.c.
2014-11-09  Richard Biener  <rguenther@suse.de>

	* match.pd: Add patterns convering two conversions in a row
	from fold-const.c.
	* fold-const.c (fold_unary_loc): Remove them here.
	* tree-ssa-forwprop.c (combine_conversions): Likewise.
	* genmatch.c (dt_node::gen_kids): Check whether we may
	follow SSA use-def chains.

	* g++.dg/cpp0x/constexpr-reinterpret1.C: XFAIL.
	* gcc.dg/tree-ssa/pr21031.c: XFAIL.

From-SVN: r217260
2014-11-09 11:27:00 +00:00
Richard Biener 5609420fba match.pd: Implement bitwise binary and unary simplifications from tree-ssa-forwprop.c.
2014-11-06  Richard Biener  <rguenther@suse.de>

	* match.pd: Implement bitwise binary and unary simplifications
	from tree-ssa-forwprop.c.
	* fold-const.c (fold_unary_loc): Remove them here.
	(fold_binary_loc): Likewise.
	* tree-ssa-forwprop.c (simplify_not_neg_expr): Remove.
	(truth_valued_ssa_name): Likewise.
	(lookup_logical_inverted_value): Likewise.
	(simplify_bitwise_binary_1): Likewise.
	(hoist_conversion_for_bitop_p): Likewise.
	(simplify_bitwise_binary_boolean): Likewise.
	(simplify_bitwise_binary): Likewise.
	(pass_forwprop::execute): Remove calls to simplify_not_neg_expr
	and simplify_bitwise_binary.
	* genmatch.c (dt_node::append_true_op): Use safe_as_a for parent.
	(decision_tree::insert): Also insert non-expressions.

	* gcc.dg/tree-ssa/forwprop-28.c: Adjust scanning for the
	desired transform.

From-SVN: r217178
2014-11-06 09:07:39 +00:00
Richard Biener 32dfd2e033 genmatch.c (expr::gen_transform): Use NOP_EXPRs instead of CONVERT_EXPRs in generated code.
2014-10-31  Richard Biener  <rguenther@suse.de>

	* genmatch.c (expr::gen_transform): Use NOP_EXPRs instead of
	CONVERT_EXPRs in generated code.
	(dt_simplify::gen): Likewise.

From-SVN: r216977
2014-10-31 13:43:53 +00:00
Richard Biener f1308e4b82 genmatch.c: Remove <map>, <utility> and <string> includes.
2014-10-30  Richard Biener  <rguenther@suse.de>

	* genmatch.c: Remove <map>, <utility> and <string> includes.
	Include ggc.h and hash-map.h.
	(ggc_internal_cleared_alloc): Provide stub definition.
	(ggc_free): Likewise.
	(struct capture_id_map_hasher): New traits for hash_map.
	(cid_map_t): New typedef.
	(everywhere else): Replace std::map use with cid_map_t.
	* hash-map.h (hash_map::elements): New member function.
	* Makefile.in (build/genmatch.o): Add $(HASH_TABLE_H),
	hash-map.h and $(GGC_H) as dependency.

From-SVN: r216940
2014-10-30 15:41:45 +00:00
Richard Biener d822570f73 genmatch.c (capture_info::walk_c_expr): Ignore capture uses inside TREE_TYPE ().
2014-10-30  Richard Biener  <rguenther@suse.de>

	* genmatch.c (capture_info::walk_c_expr): Ignore capture
	uses inside TREE_TYPE ().
	* gimple-ssa-strength-reduction.c (stmt_cost): Use CASE_CONVERT.
	(find_candidates_dom_walker::before_dom_children): Likewise.
	(replace_mult_candidate): Use CONVERT_EXPR_CODE_P.
	(replace_profitable_candidates): Likewise.
	* tree-ssa-dom.c (initialize_hash_element): Canonicalize
	CONVERT_EXPR_CODE_P to CONVERT_EXPR.
	* convert.c (convert_to_integer): Use CASE_CONVERT.

From-SVN: r216939
2014-10-30 15:36:05 +00:00
Richard Biener e0ee10ed5a genmatch.c (expr::gen_transform): Use fold_buildN_loc and build_call_expr_loc.
2014-10-24  Richard Biener  <rguenther@suse.de>

	* genmatch.c (expr::gen_transform): Use fold_buildN_loc
	and build_call_expr_loc.
	(dt_simplify::gen): Drop non_lvalue for GIMPLE, use
	non_lvalue_loc to build it for GENERIC.
	(decision_tree::gen_generic): Add location argument to
	generic_simplify prototype.
	(capture_info): New class.
	(capture_info::capture_info): New constructor.
	(capture_info::walk_match): New method.
	(capture_info::walk_result): New method.
	(capture_info::walk_c_expr): New method.
	(dt_simplify::gen): Handle preserving side-effects for
	GENERIC code generation.
	(decision_tree::gen_generic): Do not reject operands
	with TREE_SIDE_EFFECTS.
	* generic-match.h: New file.
	* generic-match-head.c: Include generic-match.h, not gimple-match.h.
	* match.pd: Add some constant folding patterns from fold-const.c.
	* fold-const.c: Include generic-match.h.
	(fold_unary_loc): Dispatch to generic_simplify.
	(fold_ternary_loc): Likewise.
	(fold_binary_loc): Likewise.  Remove patterns now implemented
	by generic_simplify.
	* gimple-fold.c (replace_stmt_with_simplification): New function.
	(fold_stmt_1): Add valueize parameter, dispatch to gimple_simplify.
	(no_follow_ssa_edges): New function.
	(fold_stmt): New overload with valueization hook.  Use
	no_follow_ssa_edges for the overload without hook.
	(fold_stmt_inplace): Likewise.
	* gimple-fold.h (no_follow_ssa_edges): Declare.

From-SVN: r216631
2014-10-24 11:00:08 +00:00
Richard Biener 3d2cf79f81 Makefile.in (OBJS): Add gimple-match.o and generic-match.o.
2014-10-22  Richard Biener  <rguenther@suse.de>
	Prathamesh Kulkarni  <bilbotheelffriend@gmail.com>

	* Makefile.in (OBJS): Add gimple-match.o and generic-match.o.
	(MOSTLYCLEANFILES): Add gimple-match.c and generic-match.c.
	(gimple-match.c): Generate by triggering s-match.
	(generic-match.c): Likewise.
	(s-match): Rule to build gimple-match.c and generic-match.c
	by running the genmatch generator program.
	(build/hash-table.o): Dependencies to build hash-table.c for the host.
	(build/genmatch.o): Dependencies to build genmatch.
	(genprog): Add match.
	(build/genmatch): Likewise.
	(TEXI_GCCINT_FILES): Add match-and-simplify.texi.
	* generic-match-head.c: New file.
	* gimple-match-head.c: Likewise.
	* gimple-match.h: Likewise.
	* genmatch.c: Likewise.
	* match.pd: Likewise.
	* builtins.h (fold_builtin_n): Export.
	* builtins.c (fold_builtin_n): Likewise.
	* gimple-fold.h (gimple_build): Declare various overloads.
	(gimple_simplify): Likewise.
	(gimple_convert): Re-implement in terms of gimple_build.
	* gimple-fold.c (gimple_convert): Remove.
	(gimple_build): New functions.

	* doc/match-and-simplify.texi: New file.
	* doc/gccint.texi: Add menu item Match and Simplify and include
	match-and-simplify.texi.

Co-Authored-By: Prathamesh Kulkarni <bilbotheelffriend@gmail.com>

From-SVN: r216542
2014-10-22 08:42:37 +00:00