2008-09-22 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 22 Sep 2008 19:15:43 +0000 (19:15 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 22 Sep 2008 19:15:43 +0000 (19:15 +0000)
PR tree-optimization/37145
* tree-ssa-sccvn.c (copy_reference_ops_from_ref): Re-enable
value-numbering union accesses with their offset and size only.
(visit_reference_op_load): Fix simplification of inserted conversions.
* tree-ssa-pre.c (find_or_generate_expression): Do not
recursively generate expressions if running FRE.

* gcc.c-torture/compile/20080922-1.c: New testcase.
* gcc.dg/tree-ssa/ssa-fre-7.c: Remove XFAIL.
* gcc.dg/tree-ssa/ssa-fre-8.c: Likewise.
* gcc.dg/tree-ssa/ssa-fre-9.c: Likewise.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20080922-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-7.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-8.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-9.c
gcc/tree-ssa-pre.c
gcc/tree-ssa-sccvn.c

index feee648..8e8d9e1 100644 (file)
@@ -1,3 +1,12 @@
+2008-09-22  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/37145
+       * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Re-enable
+       value-numbering union accesses with their offset and size only.
+       (visit_reference_op_load): Fix simplification of inserted conversions.
+       * tree-ssa-pre.c (find_or_generate_expression): Do not
+       recursively generate expressions if running FRE.
+
 2008-09-22  Adam Nemet  <anemet@caviumnetworks.com>
 
        * config/mips/mips.h (ISA_HAS_BADDU): New macro.
index 89851e5..bbc5e33 100644 (file)
@@ -1,3 +1,11 @@
+2008-09-22  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/37145
+       * gcc.c-torture/compile/20080922-1.c: New testcase.
+       * gcc.dg/tree-ssa/ssa-fre-7.c: Remove XFAIL.
+       * gcc.dg/tree-ssa/ssa-fre-8.c: Likewise.
+       * gcc.dg/tree-ssa/ssa-fre-9.c: Likewise.
+
 2008-09-22  Adam Nemet  <anemet@caviumnetworks.com>
 
        * gcc.target/mips/octeon-baddu-1.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/compile/20080922-1.c b/gcc/testsuite/gcc.c-torture/compile/20080922-1.c
new file mode 100644 (file)
index 0000000..853ec4f
--- /dev/null
@@ -0,0 +1,29 @@
+typedef struct rtx_def *rtx;
+typedef struct rtvec_def *rtvec;
+enum rtx_code { PARALLEL, SET };
+union rtunion_def {
+    rtx rt_rtx;
+    rtvec rt_rtvec;
+};
+typedef union rtunion_def rtunion;
+struct rtx_def {
+    rtunion fld;
+};
+struct rtvec_def {
+    int num_elem;
+};
+extern rtx operand;
+
+rtx peephole2_insns (rtx x0, enum rtx_code code)
+{
+  switch (code)
+    {
+      case SET:
+         operand = (((x0)->fld).rt_rtx);
+         return operand;
+      case PARALLEL:
+         if ((((((x0)->fld).rt_rtvec))->num_elem) == 2)
+           return 0;
+         break;
+    }
+}
index d93a1a2..bd81831 100644 (file)
@@ -29,10 +29,10 @@ intflt foo(intflt j)
   return a.u.k;
 }
 
-/* { dg-final { scan-tree-dump-times "Inserted pretmp" 1 "fre" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "Replaced a.u.f with pretmp" 3 "fre" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "Replaced a.u.k with j" 1 "fre" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump "= VIEW_CONVERT_EXPR<float>\\\(j_" "fre" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump "return j" "optimized" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "Inserted pretmp" 1 "fre" } } */
+/* { dg-final { scan-tree-dump-times "Replaced a.u.f with pretmp" 3 "fre" } } */
+/* { dg-final { scan-tree-dump-times "Replaced a.u.k with j" 1 "fre" } } */
+/* { dg-final { scan-tree-dump "= VIEW_CONVERT_EXPR<float>\\\(j_" "fre" } } */
+/* { dg-final { scan-tree-dump "return j" "optimized" } } */
 /* { dg-final { cleanup-tree-dump "fre" } } */
 /* { dg-final { cleanup-tree-dump "optimized" } } */
index 1494dbb..6e17bd5 100644 (file)
@@ -28,6 +28,6 @@ intflt foo(int i, int b)
     }
 }
 
-/* { dg-final { scan-tree-dump-times "Replaced u.f with pretmp" 2 "fre" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "Inserted pretmp" 2 "fre" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "Replaced u.f with pretmp" 2 "fre" } } */
+/* { dg-final { scan-tree-dump-times "Inserted pretmp" 2 "fre" } } */
 /* { dg-final { cleanup-tree-dump "fre" } } */
index 24c4ae3..18595ed 100644 (file)
@@ -23,6 +23,6 @@ void __frame_state_for1 (volatile char *state_in)
     }
 }
 
-/* { dg-final { scan-tree-dump-times "Eliminated: 1" 2 "fre" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "Insertions: 1" 2 "fre" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "Eliminated: 1" 2 "fre" } } */
+/* { dg-final { scan-tree-dump-times "Insertions: 1" 2 "fre" } } */
 /* { dg-final { cleanup-tree-dump "fre" } } */
index dd61349..cd344af 100644 (file)
@@ -2730,8 +2730,9 @@ find_or_generate_expression (basic_block block, pre_expr expr,
     }
 
   /* If it's still NULL, it must be a complex expression, so generate
-     it recursively.  */
-  if (genop == NULL)
+     it recursively.  Not so for FRE though.  */
+  if (genop == NULL
+      && !in_fre)
     {
       bitmap_set_t exprset;
       unsigned int lookfor = get_expr_value_id (expr);
index dbffff5..290b308 100644 (file)
@@ -612,21 +612,22 @@ copy_reference_ops_from_ref (tree ref, VEC(vn_reference_op_s, heap) **result)
             a matching type is not necessary and a mismatching type
             is always a spurious difference.  */
          temp.type = NULL_TREE;
-#if FIXME
          /* If this is a reference to a union member, record the union
             member size as operand.  Do so only if we are doing
             expression insertion (during FRE), as PRE currently gets
             confused with this.  */
          if (may_insert
+             && TREE_OPERAND (ref, 2) == NULL_TREE
              && TREE_CODE (DECL_CONTEXT (TREE_OPERAND (ref, 1))) == UNION_TYPE
              && integer_zerop (DECL_FIELD_OFFSET (TREE_OPERAND (ref, 1)))
              && integer_zerop (DECL_FIELD_BIT_OFFSET (TREE_OPERAND (ref, 1))))
            temp.op0 = TYPE_SIZE (TREE_TYPE (TREE_OPERAND (ref, 1)));
          else
-#endif
-           /* Record field as operand.  */
-           temp.op0 = TREE_OPERAND (ref, 1);
-           temp.op1 = TREE_OPERAND (ref, 2);     
+           {
+             /* Record field as operand.  */
+             temp.op0 = TREE_OPERAND (ref, 1);
+             temp.op1 = TREE_OPERAND (ref, 2);
+           }
          break;
        case ARRAY_RANGE_REF:
        case ARRAY_REF:
@@ -1612,7 +1613,7 @@ defs_to_varying (gimple stmt)
 }
 
 static bool expr_has_constants (tree expr);
-static tree try_to_simplify (gimple stmt);
+static tree valueize_expr (tree expr);
 
 /* Visit a copy between LHS and RHS, return true if the value number
    changed.  */
@@ -1742,12 +1743,14 @@ visit_reference_op_load (tree lhs, tree op, gimple stmt)
         So first simplify and lookup this expression to see if it
         is already available.  */
       tree val = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (op), result);
-      if (stmt
-         && !is_gimple_min_invariant (val)
-         && TREE_CODE (val) != SSA_NAME)
+      if ((CONVERT_EXPR_P (val)
+          || TREE_CODE (val) == VIEW_CONVERT_EXPR)
+         && TREE_CODE (TREE_OPERAND (val, 0)) == SSA_NAME)
         {
-         tree tem = try_to_simplify (stmt);
-         if (tem)
+         tree tem = valueize_expr (vn_get_expr_for (TREE_OPERAND (val, 0)));
+         if ((CONVERT_EXPR_P (tem)
+              || TREE_CODE (tem) == VIEW_CONVERT_EXPR)
+             && (tem = fold_unary (TREE_CODE (val), TREE_TYPE (val), tem)))
            val = tem;
        }
       result = val;