Commit 721425b6 by Kazu Hirata Committed by Kazu Hirata

re PR tree-optimization/21088 (VRP passes fold the type of operands of a comparison)

	PR tree-optimization/21088
	* fold-const.c (fold_unary, fold_binary, fold_ternary):
	Export.
	* tree-vrp.c (compare_values): Use fold_binary to compare
	pointers.  Use boolean_type_node as the type of a comparison
	expression being folded.
	* tree.h: Add prototypes for fold_unary, fold_binary,
	fold_ternary.

From-SVN: r98600
parent 84d65814
2005-04-23 Kazu Hirata <kazu@cs.umass.edu>
PR tree-optimization/21088
* fold-const.c (fold_unary, fold_binary, fold_ternary):
Export.
* tree-vrp.c (compare_values): Use fold_binary to compare
pointers. Use boolean_type_node as the type of a comparison
expression being folded.
* tree.h: Add prototypes for fold_unary, fold_binary,
fold_ternary.
2005-04-22 Diego Novillo <dnovillo@redhat.com> 2005-04-22 Diego Novillo <dnovillo@redhat.com>
* Makefile.in (tree-into-ssa.o): Add dependency on PARAMS_H. * Makefile.in (tree-into-ssa.o): Add dependency on PARAMS_H.
......
...@@ -6678,7 +6678,7 @@ fold_complex_div (tree type, tree ac, tree bc, enum tree_code code) ...@@ -6678,7 +6678,7 @@ fold_complex_div (tree type, tree ac, tree bc, enum tree_code code)
OP0. Return the folded expression if folding is successful. OP0. Return the folded expression if folding is successful.
Otherwise, return NULL_TREE. */ Otherwise, return NULL_TREE. */
static tree tree
fold_unary (enum tree_code code, tree type, tree op0) fold_unary (enum tree_code code, tree type, tree op0)
{ {
tree tem; tree tem;
...@@ -7113,7 +7113,7 @@ fold_unary (enum tree_code code, tree type, tree op0) ...@@ -7113,7 +7113,7 @@ fold_unary (enum tree_code code, tree type, tree op0)
OP0 and OP1. Return the folded expression if folding is OP0 and OP1. Return the folded expression if folding is
successful. Otherwise, return NULL_TREE. */ successful. Otherwise, return NULL_TREE. */
static tree tree
fold_binary (enum tree_code code, tree type, tree op0, tree op1) fold_binary (enum tree_code code, tree type, tree op0, tree op1)
{ {
tree t1 = NULL_TREE; tree t1 = NULL_TREE;
...@@ -9852,7 +9852,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) ...@@ -9852,7 +9852,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
OP0, OP1, and OP2. Return the folded expression if folding is OP0, OP1, and OP2. Return the folded expression if folding is
successful. Otherwise, return NULL_TREE. */ successful. Otherwise, return NULL_TREE. */
static tree tree
fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2) fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2)
{ {
tree tem; tree tem;
......
...@@ -416,17 +416,17 @@ compare_values (tree val1, tree val2) ...@@ -416,17 +416,17 @@ compare_values (tree val1, tree val2)
return 0; return 0;
/* If VAL1 is a lower address than VAL2, return -1. */ /* If VAL1 is a lower address than VAL2, return -1. */
t = fold (build2 (LT_EXPR, TREE_TYPE (val1), val1, val2)); t = fold_binary (LT_EXPR, boolean_type_node, val1, val2);
if (t == boolean_true_node) if (t == boolean_true_node)
return -1; return -1;
/* If VAL1 is a higher address than VAL2, return +1. */ /* If VAL1 is a higher address than VAL2, return +1. */
t = fold (build2 (GT_EXPR, TREE_TYPE (val1), val1, val2)); t = fold_binary (GT_EXPR, boolean_type_node, val1, val2);
if (t == boolean_true_node) if (t == boolean_true_node)
return 1; return 1;
/* If VAL1 is different than VAL2, return +2. */ /* If VAL1 is different than VAL2, return +2. */
t = fold (build2 (NE_EXPR, TREE_TYPE (val1), val1, val2)); t = fold_binary (NE_EXPR, boolean_type_node, val1, val2);
if (t == boolean_true_node) if (t == boolean_true_node)
return 2; return 2;
......
...@@ -3511,6 +3511,9 @@ extern void using_eh_for_cleanups (void); ...@@ -3511,6 +3511,9 @@ extern void using_eh_for_cleanups (void);
subexpressions are not changed. */ subexpressions are not changed. */
extern tree fold (tree); extern tree fold (tree);
extern tree fold_unary (enum tree_code, tree, tree);
extern tree fold_binary (enum tree_code, tree, tree, tree);
extern tree fold_ternary (enum tree_code, tree, tree, tree, tree);
extern tree fold_build1 (enum tree_code, tree, tree); extern tree fold_build1 (enum tree_code, tree, tree);
extern tree fold_build2 (enum tree_code, tree, tree, tree); extern tree fold_build2 (enum tree_code, tree, tree, tree);
extern tree fold_build3 (enum tree_code, tree, tree, tree, tree); extern tree fold_build3 (enum tree_code, tree, tree, tree, tree);
......
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