Re: [PATCH 04/89] Introduce gimple_cond and use it in various places

2014-05-09 Thread Jeff Law

On 04/21/14 10:56, David Malcolm wrote:

gcc/
* coretypes.h (gimple_cond): New typedef.
(const_gimple_cond): Likewise.

* gimple.h (struct gimple_statement_cond): New subclass of
gimple_statement_with_ops, adding the invariant that
stmt-code == GIMPLE_COND.
(gimple_statement_base::as_a_gimple_cond): New.
(gimple_statement_base::dyn_cast_gimple_cond): New.
(is_a_helper gimple_statement_cond::test): New.
(gimple_build_cond): Return a gimple_cond, rather than just
a gimple.
(gimple_build_cond_from_tree): Likewise.

* gdbhooks.py (build_pretty_printer): Add gimple_cond and its
variants, using the gimple printer.

* cfgexpand.c (expand_gimple_cond): Require a gimple_cond rather
than just a gimple.
* gimple.h (gimple_cond_set_condition_from_tree): Likewise.
(gimple_cond_true_p): Likewise.
(gimple_cond_false_p): Likewise.
(gimple_cond_set_condition): Likewise.
* gimple.c (gimple_cond_set_condition_from_tree): Likewise.
* gimple-fold.c (fold_gimple_cond): Likewise.
* gimple-pretty-print.c (dump_gimple_cond): Likewise.
* tree-ssa-dom.c (canonicalize_comparison): Likewise.
* tree-ssa-forwprop.c (forward_propagate_into_gimple_cond): Likewise.
* tree-ssa-ifcombine.c (recognize_single_bit_test): Likewise.
(recognize_bits_test): Likewise.
* tree-ssa-threadedge.c (simplify_control_stmt_condition): Likewise.
(thread_around_empty_blocks): Likewise.
(thread_through_normal_block): Likewise.
(thread_across_edge): Likewise.
* tree-ssa-threadedge.h (thread_across_edge): Likewise.
* tree-vrp.c (range_fits_type_p): Likewise.

* cfgexpand.c (expand_gimple_basic_block): Add checked cast to
gimple_cond in regions where a stmt is known to have code GIMPLE_COND.
* gimple-fold.c (fold_stmt_1): Likewise.
* gimple-pretty-print.c (pp_gimple_stmt_1): Likewise.
* tree-ssa-dom.c (optimize_stmt): Likewise.
* tree-ssa-forwprop.c (ssa_forward_propagate_and_combine): Likewise.
* tree-ssa-loop-unswitch.c (tree_unswitch_single_loop): Likewise.
* tree-vrp.c (simplify_stmt_using_ranges): Likewise.

* cfgloopmanip.c (create_empty_loop_on_edge): Update local to be a
gimple_cond.
* tree-vrp.c (identify_jump_threads): Likewise.

* gimple.c (gimple_build_cond): Return a gimple_cond, rather than
just a gimple.
(gimple_build_cond_from_tree): Likewise.

* tree-ssa-dom.c (class dom_opt_dom_walker): Strengthen type of
field m_dummy_cond from a plain gimple to a gimple_cond.

* tree-ssa-ifcombine.c (ifcombine_ifandif): Introduce locals
inner_stmt and outer_stmt so that inner_cond and outer_cond can be
of type gimple_cond once we know that we have code == GIMPLE_COND.
* tree-ssa-loop-unswitch.c (tree_may_unswitch_on): Introduce local
last so that stmt can be of type gimple_cond.
This is generally fine.  It needs minor tweaks due to the change in how 
we're handling const stuff, but otherwise it looks ready to go.


So, once you've flushed the queue of dependencies and reworked this to 
fit into the new world order, it's OK for the trunk.  Please post the 
final version for archival purposes.


jeff



[PATCH 04/89] Introduce gimple_cond and use it in various places

2014-04-21 Thread David Malcolm
gcc/
* coretypes.h (gimple_cond): New typedef.
(const_gimple_cond): Likewise.

* gimple.h (struct gimple_statement_cond): New subclass of
gimple_statement_with_ops, adding the invariant that
stmt-code == GIMPLE_COND.
(gimple_statement_base::as_a_gimple_cond): New.
(gimple_statement_base::dyn_cast_gimple_cond): New.
(is_a_helper gimple_statement_cond::test): New.
(gimple_build_cond): Return a gimple_cond, rather than just
a gimple.
(gimple_build_cond_from_tree): Likewise.

* gdbhooks.py (build_pretty_printer): Add gimple_cond and its
variants, using the gimple printer.

* cfgexpand.c (expand_gimple_cond): Require a gimple_cond rather
than just a gimple.
* gimple.h (gimple_cond_set_condition_from_tree): Likewise.
(gimple_cond_true_p): Likewise.
(gimple_cond_false_p): Likewise.
(gimple_cond_set_condition): Likewise.
* gimple.c (gimple_cond_set_condition_from_tree): Likewise.
* gimple-fold.c (fold_gimple_cond): Likewise.
* gimple-pretty-print.c (dump_gimple_cond): Likewise.
* tree-ssa-dom.c (canonicalize_comparison): Likewise.
* tree-ssa-forwprop.c (forward_propagate_into_gimple_cond): Likewise.
* tree-ssa-ifcombine.c (recognize_single_bit_test): Likewise.
(recognize_bits_test): Likewise.
* tree-ssa-threadedge.c (simplify_control_stmt_condition): Likewise.
(thread_around_empty_blocks): Likewise.
(thread_through_normal_block): Likewise.
(thread_across_edge): Likewise.
* tree-ssa-threadedge.h (thread_across_edge): Likewise.
* tree-vrp.c (range_fits_type_p): Likewise.

* cfgexpand.c (expand_gimple_basic_block): Add checked cast to
gimple_cond in regions where a stmt is known to have code GIMPLE_COND.
* gimple-fold.c (fold_stmt_1): Likewise.
* gimple-pretty-print.c (pp_gimple_stmt_1): Likewise.
* tree-ssa-dom.c (optimize_stmt): Likewise.
* tree-ssa-forwprop.c (ssa_forward_propagate_and_combine): Likewise.
* tree-ssa-loop-unswitch.c (tree_unswitch_single_loop): Likewise.
* tree-vrp.c (simplify_stmt_using_ranges): Likewise.

* cfgloopmanip.c (create_empty_loop_on_edge): Update local to be a
gimple_cond.
* tree-vrp.c (identify_jump_threads): Likewise.

* gimple.c (gimple_build_cond): Return a gimple_cond, rather than
just a gimple.
(gimple_build_cond_from_tree): Likewise.

* tree-ssa-dom.c (class dom_opt_dom_walker): Strengthen type of
field m_dummy_cond from a plain gimple to a gimple_cond.

* tree-ssa-ifcombine.c (ifcombine_ifandif): Introduce locals
inner_stmt and outer_stmt so that inner_cond and outer_cond can be
of type gimple_cond once we know that we have code == GIMPLE_COND.
* tree-ssa-loop-unswitch.c (tree_may_unswitch_on): Introduce local
last so that stmt can be of type gimple_cond.
---
 gcc/cfgexpand.c  |  4 ++--
 gcc/cfgloopmanip.c   |  2 +-
 gcc/coretypes.h  |  4 
 gcc/gdbhooks.py  |  2 ++
 gcc/gimple-fold.c|  4 ++--
 gcc/gimple-pretty-print.c|  4 ++--
 gcc/gimple.c | 10 +-
 gcc/gimple.h | 43 +--
 gcc/tree-ssa-dom.c   |  6 +++---
 gcc/tree-ssa-forwprop.c  |  5 +++--
 gcc/tree-ssa-ifcombine.c | 21 -
 gcc/tree-ssa-loop-unswitch.c | 19 ---
 gcc/tree-ssa-threadedge.c|  8 
 gcc/tree-ssa-threadedge.h|  2 +-
 gcc/tree-vrp.c   |  6 +++---
 15 files changed, 93 insertions(+), 47 deletions(-)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 05ab95e..679933d 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -2007,7 +2007,7 @@ maybe_cleanup_end_of_block (edge e, rtx last)
block and created a new one.  */
 
 static basic_block
-expand_gimple_cond (basic_block bb, gimple stmt)
+expand_gimple_cond (basic_block bb, gimple_cond stmt)
 {
   basic_block new_bb, dest;
   edge new_edge;
@@ -5014,7 +5014,7 @@ expand_gimple_basic_block (basic_block bb, bool 
disable_tail_calls)
 fixup the CFG accordingly.  */
   if (gimple_code (stmt) == GIMPLE_COND)
{
- new_bb = expand_gimple_cond (bb, stmt);
+ new_bb = expand_gimple_cond (bb, stmt-as_a_gimple_cond ());
  if (new_bb)
return new_bb;
}
diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c
index 83a0d51..3fa2535 100644
--- a/gcc/cfgloopmanip.c
+++ b/gcc/cfgloopmanip.c
@@ -776,7 +776,7 @@ create_empty_loop_on_edge (edge entry_edge,
   struct loop *loop;
   gimple_stmt_iterator gsi;
   gimple_seq stmts;
-  gimple cond_expr;
+  gimple_cond cond_expr;
   tree exit_test;
   edge exit_e;
   int prob;
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index a39900f..68172f7