This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gimple-classes, committed 75/92] Concretize various expressions from gimple to gimple_cond
- From: David Malcolm <dmalcolm at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: David Malcolm <dmalcolm at redhat dot com>
- Date: Mon, 27 Oct 2014 16:41:13 -0400
- Subject: [gimple-classes, committed 75/92] Concretize various expressions from gimple to gimple_cond
- Authentication-results: sourceware.org; auth=none
- References: <1414442490-14841-1-git-send-email-dmalcolm at redhat dot com>
This corresponds to:
[PATCH 77/89] Concretize various expressions from gimple to gimple_cond
https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01196.html
from the original 89-patch kit
That earlier patch was approved by Jeff:
> OK once prereqs go in.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00858.html
gcc/
* ipa-split.c (check_forbidden_calls): Replace check against
GIMPLE_COND with a dyn_cast<gimple_cond>, introducing a
gimple_cond local.
* predict.c (predict_extra_loop_exits): Likewise.
* tree-vrp.c (fold_predicate_in): Likewise.
(simplify_stmt_for_jump_threading): Likewise.
* predict.c (is_comparison_with_loop_invariant_p): Require a
gimple_cond.
(predict_iv_comparison): Add checked cast to gimple_cond once we
know the code is GIMPLE_COND.
(predict_loops): Change type of "stmt" to gimple_cond,
adding checked casts to its assignments (which are both guarded by
checks against GIMPLE_COND).
* tree-vrp.c (find_conditional_asserts): Require a gimple_cond.
(vrp_evaluate_conditional): Likewise.
(find_assert_locations_1): Add checked cast to gimple_cond.
(vrp_visit_stmt): Likewise.
---
gcc/ChangeLog.gimple-classes | 24 ++++++++++++++++++++++++
gcc/ipa-split.c | 5 +++--
gcc/predict.c | 21 ++++++++++++++-------
gcc/tree-vrp.c | 25 +++++++++++++------------
4 files changed, 54 insertions(+), 21 deletions(-)
diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index a5fd662..86e1718 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,29 @@
2014-10-24 David Malcolm <dmalcolm@redhat.com>
+ Concretize various expressions from gimple to gimple_cond
+
+ * ipa-split.c (check_forbidden_calls): Replace check against
+ GIMPLE_COND with a dyn_cast<gimple_cond>, introducing a
+ gimple_cond local.
+ * predict.c (predict_extra_loop_exits): Likewise.
+ * tree-vrp.c (fold_predicate_in): Likewise.
+ (simplify_stmt_for_jump_threading): Likewise.
+
+ * predict.c (is_comparison_with_loop_invariant_p): Require a
+ gimple_cond.
+ (predict_iv_comparison): Add checked cast to gimple_cond once we
+ know the code is GIMPLE_COND.
+ (predict_loops): Change type of "stmt" to gimple_cond,
+ adding checked casts to its assignments (which are both guarded by
+ checks against GIMPLE_COND).
+
+ * tree-vrp.c (find_conditional_asserts): Require a gimple_cond.
+ (vrp_evaluate_conditional): Likewise.
+ (find_assert_locations_1): Add checked cast to gimple_cond.
+ (vrp_visit_stmt): Likewise.
+
+2014-10-24 David Malcolm <dmalcolm@redhat.com>
+
Concretize gimple_cond_{lhs|rhs}_ptr
* gimple.h (gimple_cond_lhs_ptr): Require a const_gimple_cond
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index e5df578..08dbf7d 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -353,9 +353,10 @@ check_forbidden_calls (gimple stmt)
basic_block use_bb, forbidden_bb;
enum tree_code code;
edge true_edge, false_edge;
- gimple use_stmt = USE_STMT (use_p);
+ gimple_cond use_stmt;
- if (gimple_code (use_stmt) != GIMPLE_COND)
+ use_stmt = dyn_cast <gimple_cond> (USE_STMT (use_p));
+ if (!use_stmt)
continue;
/* Assuming canonical form for GIMPLE_COND here, with constant
diff --git a/gcc/predict.c b/gcc/predict.c
index c21cc29..38d4a1d 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -1104,7 +1104,7 @@ get_base_value (tree t)
Otherwise return false and set LOOP_INVAIANT to NULL. */
static bool
-is_comparison_with_loop_invariant_p (gimple stmt, struct loop *loop,
+is_comparison_with_loop_invariant_p (gimple_cond stmt, struct loop *loop,
tree *loop_invariant,
enum tree_code *compare_code,
tree *loop_step,
@@ -1269,7 +1269,8 @@ predict_iv_comparison (struct loop *loop, basic_block bb,
stmt = last_stmt (bb);
if (!stmt || gimple_code (stmt) != GIMPLE_COND)
return;
- if (!is_comparison_with_loop_invariant_p (stmt, loop, &compare_var,
+ if (!is_comparison_with_loop_invariant_p (as_a <gimple_cond> (stmt),
+ loop, &compare_var,
&compare_code,
&compare_step_var,
&compare_base))
@@ -1445,10 +1446,16 @@ predict_extra_loop_exits (edge exit_edge)
gimple lhs_def_stmt;
gimple_phi phi_stmt;
tree cmp_rhs, cmp_lhs;
- gimple cmp_stmt = last_stmt (exit_edge->src);
+ gimple last;
+ gimple_cond cmp_stmt;
- if (!cmp_stmt || gimple_code (cmp_stmt) != GIMPLE_COND)
+ last = last_stmt (exit_edge->src);
+ if (!last)
+ return;
+ cmp_stmt = dyn_cast <gimple_cond> (last);
+ if (!cmp_stmt)
return;
+
cmp_rhs = gimple_cond_rhs (cmp_stmt);
cmp_lhs = gimple_cond_lhs (cmp_stmt);
if (!TREE_CONSTANT (cmp_rhs)
@@ -1515,7 +1522,7 @@ predict_loops (void)
tree loop_bound_step = NULL;
tree loop_bound_var = NULL;
tree loop_iv_base = NULL;
- gimple stmt = NULL;
+ gimple_cond stmt = NULL;
exits = get_loop_exit_edges (loop);
n_exits = exits.length ();
@@ -1582,12 +1589,12 @@ predict_loops (void)
if (nb_iter->stmt
&& gimple_code (nb_iter->stmt) == GIMPLE_COND)
{
- stmt = nb_iter->stmt;
+ stmt = as_a <gimple_cond> (nb_iter->stmt);
break;
}
if (!stmt && last_stmt (loop->header)
&& gimple_code (last_stmt (loop->header)) == GIMPLE_COND)
- stmt = last_stmt (loop->header);
+ stmt = as_a <gimple_cond> (last_stmt (loop->header));
if (stmt)
is_comparison_with_loop_invariant_p (stmt, loop,
&loop_bound_var,
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index afd54bf..303af8d 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -5701,7 +5701,7 @@ register_edge_assert_for (tree name, edge e, gimple_stmt_iterator si,
list of assertions for the corresponding operands. */
static bool
-find_conditional_asserts (basic_block bb, gimple last)
+find_conditional_asserts (basic_block bb, gimple_cond last)
{
bool need_assert;
gimple_stmt_iterator bsi;
@@ -5943,7 +5943,7 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
&& gimple_code (last) == GIMPLE_COND
&& !fp_predicate (last)
&& !ZERO_SSA_OPERANDS (last, SSA_OP_USE))
- need_assert |= find_conditional_asserts (bb, last);
+ need_assert |= find_conditional_asserts (bb, as_a <gimple_cond> (last));
/* If BB's last statement is a switch statement involving integer
operands, determine if we need to add ASSERT_EXPRs. */
@@ -7318,7 +7318,7 @@ vrp_evaluate_conditional (enum tree_code code, tree op0, tree op1, gimple stmt)
SSA_PROP_VARYING. */
static enum ssa_prop_result
-vrp_visit_cond_stmt (gimple stmt, edge *taken_edge_p)
+vrp_visit_cond_stmt (gimple_cond stmt, edge *taken_edge_p)
{
tree val;
bool sop;
@@ -7730,7 +7730,7 @@ vrp_visit_stmt (gimple stmt, edge *taken_edge_p, tree *output_p)
else if (is_gimple_assign (stmt) || is_gimple_call (stmt))
return vrp_visit_assignment_or_call (stmt, output_p);
else if (gimple_code (stmt) == GIMPLE_COND)
- return vrp_visit_cond_stmt (stmt, taken_edge_p);
+ return vrp_visit_cond_stmt (as_a <gimple_cond> (stmt), taken_edge_p);
else if (gimple_code (stmt) == GIMPLE_SWITCH)
return vrp_visit_switch_stmt (as_a <gimple_switch> (stmt), taken_edge_p);
@@ -9644,10 +9644,10 @@ fold_predicate_in (gimple_stmt_iterator *si)
gimple_assign_rhs2 (stmt),
stmt);
}
- else if (gimple_code (stmt) == GIMPLE_COND)
- val = vrp_evaluate_conditional (gimple_cond_code (stmt),
- gimple_cond_lhs (stmt),
- gimple_cond_rhs (stmt),
+ else if (gimple_cond cond_stmt = dyn_cast <gimple_cond> (stmt))
+ val = vrp_evaluate_conditional (gimple_cond_code (cond_stmt),
+ gimple_cond_lhs (cond_stmt),
+ gimple_cond_rhs (cond_stmt),
stmt);
else
return false;
@@ -9712,10 +9712,11 @@ static vec<tree> equiv_stack;
static tree
simplify_stmt_for_jump_threading (gimple stmt, gimple within_stmt)
{
- if (gimple_code (stmt) == GIMPLE_COND)
- return vrp_evaluate_conditional (gimple_cond_code (stmt),
- gimple_cond_lhs (stmt),
- gimple_cond_rhs (stmt), within_stmt);
+ if (gimple_cond cond_stmt = dyn_cast <gimple_cond> (stmt))
+ return vrp_evaluate_conditional (gimple_cond_code (cond_stmt),
+ gimple_cond_lhs (cond_stmt),
+ gimple_cond_rhs (cond_stmt),
+ within_stmt);
if (gimple_assign assign_stmt = dyn_cast <gimple_assign> (stmt))
{
--
1.8.5.3