OSDN Git Service

* tree-vrp.c (test_for_singularity): Correct test for new
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 Jan 2006 19:47:16 +0000 (19:47 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 Jan 2006 19:47:16 +0000 (19:47 +0000)
min limit.  Use operand_equal_p rather than pointer equality
for testing if new min/max values are equal.

* tree-ssa-propagate.c (substitute_and_fold): Delay simplifications
using range information until after propagation and folding.

* gcc.c-torture/execute/930529-1.x: Use -fwrapv as test depends
on wrapping on overflow semantics.

* gcc.dg/tree-ssa/pr23109.c: Remove the .lim file too.

* gcc.gc/tree-ssa/vrp23.c: New test.
* gcc.gc/tree-ssa/vrp24.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@109904 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/930529-1.x
gcc/testsuite/gcc.dg/tree-ssa/pr23109.c
gcc/testsuite/gcc.dg/tree-ssa/vrp23.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/vrp24.c [new file with mode: 0644]
gcc/tree-ssa-propagate.c
gcc/tree-vrp.c

index b57d517..d6c62f6 100644 (file)
@@ -1,3 +1,12 @@
+2006-01-18  Jeff Law  <law@redhat.com>
+
+       * tree-vrp.c (test_for_singularity): Correct test for new
+       min limit.  Use operand_equal_p rather than pointer equality
+       for testing if new min/max values are equal.
+
+       * tree-ssa-propagate.c (substitute_and_fold): Delay simplifications
+       using range information until after propagation and folding.
+
 2006-01-18  Richard Henderson  <rth@redhat.com>
            Aldy Hernandez  <aldyh@redhat.com>
            Jakub Jelinek  <jakub@redhat.com>
index 15e4761..f797394 100644 (file)
@@ -1,3 +1,13 @@
+2006-01-18  Jeff Law  <law@redhat.com>
+
+       * gcc.c-torture/execute/930529-1.x: Use -fwrapv as test depends
+       on wrapping on overflow semantics.
+
+       * gcc.dg/tree-ssa/pr23109.c: Remove the .lim file too.
+
+       * gcc.gc/tree-ssa/vrp23.c: New test.
+       * gcc.gc/tree-ssa/vrp24.c: New test.
+
 2006-01-18  Richard Henderson  <rth@redhat.com>
            Aldy Hernandez  <aldyh@redhat.com>
            Jakub Jelinek  <jakub@redhat.com>
index e121a55..b620fa4 100644 (file)
@@ -31,4 +31,5 @@ int main()
 /* { dg-final { scan-tree-dump-not "reciptmp" "lim" } } */
 /* { dg-final { scan-tree-dump-not "reciptmp" "recip" } } */
 /* { dg-final { cleanup-tree-dump "recip" } } */
+/* { dg-final { cleanup-tree-dump "lim" } } */
 
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp23.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp23.c
new file mode 100644 (file)
index 0000000..c394d4a
--- /dev/null
@@ -0,0 +1,45 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp-details" } */
+
+blah (int code1, int code2)
+{
+  int i;
+  int n_sets;
+
+  n_sets = (int) (code1 == 32);
+  if (code2 == 64) goto L2; else goto L3;
+
+L2:
+  aa ();
+
+L3:
+  if (n_sets > 1) goto L4; else goto L10;
+
+L4:
+  aos ();
+  i = 0;
+  goto L24;
+
+L10:
+  if (n_sets > 0) goto L25; else goto L8;
+
+L25:
+  i = 0;
+
+L24:
+  aob ();
+  i = i + 1;
+  if (i < n_sets) goto L24; else goto L8;
+
+L8:
+  return;
+}
+
+
+
+/* The n_sets > 0 test can be simplified into n_sets == 1 since the
+   only way to reach the test is when n_sets <= 1, and the only value
+   which satisfies both conditions is n_sets == 1.  */
+/* { dg-final { scan-tree-dump-times "Simplified relational" 1 "vrp" } } */
+/* { dg-final { cleanup-tree-dump "vrp" } } */
+
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp24.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp24.c
new file mode 100644 (file)
index 0000000..3be7efa
--- /dev/null
@@ -0,0 +1,89 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp-details" } */
+
+
+struct rtx_def;
+typedef struct rtx_def *rtx;
+union rtunion_def
+{
+  rtx rt_rtx;
+};
+typedef union rtunion_def rtunion;
+struct rtx_def
+{
+  int code;
+  union u
+  {
+    rtunion fld[1];
+  } u;
+};
+
+sss (rtx insn, int code1, int code2, int code3)
+{
+  _Bool D1562;
+  struct rtx_def * body;
+  int i;
+  int n_sets;
+  int D1544;
+
+  body = insn->u.fld[5].rt_rtx;
+  D1544 = body->code;
+  n_sets = 1;
+  if (D1544 == 55) goto L7; else goto L1;
+
+L1:
+  n_sets = 0;
+  if (code3 == 99) goto L2; else goto L11;
+
+L2:
+  D1562 = code1 == 10;
+  n_sets = (int) D1562;
+  if (n_sets > 0) goto L7; else goto L11;
+
+L37:
+  if (code2 == 42) goto L8; else goto L9;
+
+L8:
+  arf ();
+
+L9:
+  i = i + 1;
+  if (i < n_sets) goto L37; else goto L32;
+
+L32:
+
+L11:
+  if (n_sets > 1) goto L12; else goto L15;
+
+L12:
+  nit ();
+
+L14:
+  i = 0;
+  goto L38;
+
+L15:
+  if (n_sets > 0) goto L14; else goto L16;
+
+L38:
+  frob ();
+  i = i + 1;
+  if (n_sets > i) goto L38; else goto L16;
+
+L16:
+  return;
+
+L7:
+  i = 0;
+  goto L37;
+
+}
+
+
+
+/* The n_sets > 0 test can be simplified into n_sets == 1 since the
+   only way to reach the test is when n_sets <= 1, and the only value
+   which satisfies both conditions is n_sets == 1.  */
+/* { dg-final { scan-tree-dump-times "Simplified relational" 1 "vrp" } } */
+/* { dg-final { cleanup-tree-dump "vrp" } } */
+
index d8ba253..dcdc6ad 100644 (file)
@@ -1,5 +1,5 @@
 /* Generic SSA value propagation engine.
-   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
    Contributed by Diego Novillo <dnovillo@redhat.com>
 
    This file is part of GCC.
@@ -1124,14 +1124,7 @@ substitute_and_fold (prop_value_t *prop_value, bool use_ranges_p)
          /* If we have range information, see if we can fold
             predicate expressions.  */
          if (use_ranges_p)
-           {
-             did_replace = fold_predicate_in (stmt);
-
-             /* Some statements may be simplified using ranges.  For
-                example, division may be replaced by shifts, modulo
-                replaced with bitwise and, etc.  */
-             simplify_stmt_using_ranges (stmt);
-           }
+           did_replace = fold_predicate_in (stmt);
 
          if (prop_value)
            {
@@ -1178,6 +1171,16 @@ substitute_and_fold (prop_value_t *prop_value, bool use_ranges_p)
                  fprintf (dump_file, "\n");
                }
            }
+
+         /* Some statements may be simplified using ranges.  For
+            example, division may be replaced by shifts, modulo
+            replaced with bitwise and, etc.   Do this after 
+            substituting constants, folding, etc so that we're
+            presented with a fully propagated, canonicalized
+            statement.  */
+         if (use_ranges_p)
+           simplify_stmt_using_ranges (stmt);
+
        }
     }
 
index 7fcd62d..a5028b4 100644 (file)
@@ -1,5 +1,5 @@
 /* Support routines for Value Range Propagation (VRP).
-   Copyright (C) 2005 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
    Contributed by Diego Novillo <dnovillo@redhat.com>.
 
 This file is part of GCC.
@@ -3970,7 +3970,7 @@ test_for_singularity (enum tree_code cond_code, tree op0,
       if (cond_code == GT_EXPR)
        {
          tree one = build_int_cst (TREE_TYPE (op0), 1);
-         max = fold_build2 (PLUS_EXPR, TREE_TYPE (op0), max, one);
+         min = fold_build2 (PLUS_EXPR, TREE_TYPE (op0), min, one);
        }
     }
 
@@ -3987,10 +3987,10 @@ test_for_singularity (enum tree_code cond_code, tree op0,
       else
        max = vr->max;
 
-      /* If the new min/max values have converged to a
-        single value, then there is only one value which
-        can satisfy the condition, return that value.  */
-      if (min == max && is_gimple_min_invariant (min))
+      /* If the new min/max values have converged to a single value,
+        then there is only one value which can satisfy the condition,
+        return that value.  */
+      if (operand_equal_p (min, max, 0) && is_gimple_min_invariant (min))
        return min;
     }
   return NULL;