Commit 764a79ed by Rafael Avila de Espindola Committed by Rafael Espindola

tree-vrp.c (extract_code_and_val_from_cond_with_ops): New.

2008-04-01  Rafael Espindola  <espindola@google.com>

	* tree-vrp.c (extract_code_and_val_from_cond_with_ops): New.
	(extract_code_and_val_from_cond): Use
	extract_code_and_val_from_cond_with_ops.

From-SVN: r133789
parent 113c63b8
2008-04-01 Rafael Espindola <espindola@google.com>
* tree-vrp.c (extract_code_and_val_from_cond_with_ops): New.
(extract_code_and_val_from_cond): Use
extract_code_and_val_from_cond_with_ops.
2008-04-01 Jan Hubicka <jh@suse.cz> 2008-04-01 Jan Hubicka <jh@suse.cz>
* function.c (free_after_compilation): Free epilogue_delay_list. * function.c (free_after_compilation): Free epilogue_delay_list.
......
...@@ -3623,48 +3623,33 @@ register_new_assert_for (tree name, tree expr, ...@@ -3623,48 +3623,33 @@ register_new_assert_for (tree name, tree expr,
bitmap_set_bit (need_assert_for, SSA_NAME_VERSION (name)); bitmap_set_bit (need_assert_for, SSA_NAME_VERSION (name));
} }
/* COND is a predicate which uses NAME. Extract a suitable test code /* Helper function for extract_code_and_val_from_cond */
and value and store them into *CODE_P and *VAL_P so the predicate
is normalized to NAME *CODE_P *VAL_P.
If no extraction was possible, return FALSE, otherwise return TRUE.
If INVERT is true, then we invert the result stored into *CODE_P. */
static bool static bool
extract_code_and_val_from_cond (tree name, tree cond, bool invert, extract_code_and_val_from_cond_with_ops (tree name, enum tree_code cond_code,
enum tree_code *code_p, tree *val_p) tree cond_op0, tree cond_op1,
bool invert, enum tree_code *code_p,
tree *val_p)
{ {
enum tree_code comp_code; enum tree_code comp_code;
tree val; tree val;
/* Predicates may be a single SSA name or NAME OP VAL. */
if (cond == name)
{
/* If the predicate is a name, it must be NAME, in which
case we create the predicate NAME == true or
NAME == false accordingly. */
comp_code = EQ_EXPR;
val = invert ? boolean_false_node : boolean_true_node;
}
else
{
/* Otherwise, we have a comparison of the form NAME COMP VAL /* Otherwise, we have a comparison of the form NAME COMP VAL
or VAL COMP NAME. */ or VAL COMP NAME. */
if (name == TREE_OPERAND (cond, 1)) if (name == cond_op1)
{ {
/* If the predicate is of the form VAL COMP NAME, flip /* If the predicate is of the form VAL COMP NAME, flip
COMP around because we need to register NAME as the COMP around because we need to register NAME as the
first operand in the predicate. */ first operand in the predicate. */
comp_code = swap_tree_comparison (TREE_CODE (cond)); comp_code = swap_tree_comparison (cond_code);
val = TREE_OPERAND (cond, 0); val = cond_op0;
} }
else else
{ {
/* The comparison is of the form NAME COMP VAL, so the /* The comparison is of the form NAME COMP VAL, so the
comparison code remains unchanged. */ comparison code remains unchanged. */
comp_code = TREE_CODE (cond); comp_code = cond_code;
val = TREE_OPERAND (cond, 1); val = cond_op1;
} }
/* Invert the comparison code as necessary. */ /* Invert the comparison code as necessary. */
...@@ -3695,11 +3680,44 @@ extract_code_and_val_from_cond (tree name, tree cond, bool invert, ...@@ -3695,11 +3680,44 @@ extract_code_and_val_from_cond (tree name, tree cond, bool invert,
|| compare_values (val, min) == 0)) || compare_values (val, min) == 0))
return false; return false;
} }
}
*code_p = comp_code; *code_p = comp_code;
*val_p = val; *val_p = val;
return true; return true;
} }
/* COND is a predicate which uses NAME. Extract a suitable test code
and value and store them into *CODE_P and *VAL_P so the predicate
is normalized to NAME *CODE_P *VAL_P.
If no extraction was possible, return FALSE, otherwise return TRUE.
If INVERT is true, then we invert the result stored into *CODE_P. */
static bool
extract_code_and_val_from_cond (tree name, tree cond, bool invert,
enum tree_code *code_p, tree *val_p)
{
enum tree_code comp_code;
tree val;
/* Predicates may be a single SSA name or NAME OP VAL. */
if (cond == name)
{
/* If the predicate is a name, it must be NAME, in which
case we create the predicate NAME == true or
NAME == false accordingly. */
comp_code = EQ_EXPR;
val = invert ? boolean_false_node : boolean_true_node;
*code_p = comp_code;
*val_p = val;
return true;
}
else
return extract_code_and_val_from_cond_with_ops (name, TREE_CODE (cond),
TREE_OPERAND (cond, 0),
TREE_OPERAND (cond, 1),
invert,
code_p, val_p);
}
/* Try to register an edge assertion for SSA name NAME on edge E for /* Try to register an edge assertion for SSA name NAME on edge E for
the condition COND contributing to the conditional jump pointed to by BSI. the condition COND contributing to the conditional jump pointed to by BSI.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment