aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2004-05-14 17:51:05 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2004-05-14 17:51:05 +0000
commit9fb994de761a002454e2b01e07db96579429bec7 (patch)
treebc5a65b08d1433084d256e36182e0a2524cf09f1
parent03a72b0fe5b07e96de0fe4343b3d493030fbc2a3 (diff)
* tree-ssa-dom.c (simplify_rhs_and_lookup_avail_expr): Reorganize
so that it picks up more opportunities to eliminate ABS expressions or turn them into negations. * gcc.dg/tree-ssa/20040514-2.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@81853 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/20040514-2.c15
-rw-r--r--gcc/tree-ssa-dom.c24
4 files changed, 47 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 67de34125e3..844500dce72 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2004-05-14 Jeff Law <law@redhat.com>
+
+ * tree-ssa-dom.c (simplify_rhs_and_lookup_avail_expr): Reorganize
+ so that it picks up more opportunities to eliminate ABS expressions
+ or turn them into negations.
+
2004-05-14 Steven Bosscher <stevenb@suse.de>
* passes.c (rest_of_handle_null_pointer): Remove.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6269855cfac..77a80bad099 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2004-05-14 Jeff Law <law@redhat.com>
+
+ * gcc.dg/tree-ssa/20040514-2.c: New test.
+
2004-05-14 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
* gfortran.fortran-torture/compile/noncontinuation_1.f90: Rename
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20040514-2.c b/gcc/testsuite/gcc.dg/tree-ssa/20040514-2.c
new file mode 100644
index 00000000000..b651ae32cf9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/20040514-2.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-dom3" } */
+int
+foo2 (distance, i, j)
+ int distance;
+ int i, j;
+{
+ int t = distance;
+ if (t <= 0)
+ t = ((t) >= 0 ? (t) : -(t));
+ return t;
+}
+
+/* There should be no ABS_EXPR. */
+/* { dg-final { scan-tree-dump-times "ABS_EXPR " 0 "dom3"} } */
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index ed47ea6c2c2..89f4c6a5cb0 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -1826,7 +1826,7 @@ simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data,
if (! dummy_cond)
{
- dummy_cond = build (LT_EXPR, boolean_type_node,
+ dummy_cond = build (LE_EXPR, boolean_type_node,
op, integer_zero_node);
dummy_cond = build (COND_EXPR, void_type_node,
dummy_cond, NULL, NULL);
@@ -1834,7 +1834,7 @@ simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data,
}
else
{
- TREE_SET_CODE (TREE_OPERAND (dummy_cond, 0), LT_EXPR);
+ TREE_SET_CODE (TREE_OPERAND (dummy_cond, 0), LE_EXPR);
TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 0) = op;
TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 1)
= convert (type, integer_zero_node);
@@ -1842,6 +1842,26 @@ simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data,
val = simplify_cond_and_lookup_avail_expr (dummy_cond,
&bd->avail_exprs,
NULL, false);
+
+ if (!val)
+ {
+ TREE_SET_CODE (TREE_OPERAND (dummy_cond, 0), GE_EXPR);
+ TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 0) = op;
+ TREE_OPERAND (TREE_OPERAND (dummy_cond, 0), 1)
+ = convert (type, integer_zero_node);
+
+ val = simplify_cond_and_lookup_avail_expr (dummy_cond,
+ &bd->avail_exprs,
+ NULL, false);
+
+ if (val)
+ {
+ if (integer_zerop (val))
+ val = integer_one_node;
+ else if (integer_onep (val))
+ val = integer_zero_node;
+ }
+ }
}
if (val