re PR tree-optimization/49645 (g++.dg/tree-ssa/pr8781.C FAILs on Tru64 UNIX)
authorRichard Guenther <rguenther@suse.de>
Wed, 6 Jul 2011 14:05:54 +0000 (14:05 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 6 Jul 2011 14:05:54 +0000 (14:05 +0000)
2011-07-06  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/49645
* c-decl.c (finish_decl): Also set DECL_HARD_REGISTER for global
register variables.
* tree-ssa-sccvn.c (vn_reference_op_eq): Disregard differences
in type qualification here ...
(copy_reference_ops_from_ref): ... not here.
(vn_reference_lookup_3): ... or here.
(copy_reference_ops_from_ref): Record decl bases as MEM[&decl].
(vn_reference_lookup): Do the lookup with a valueized ao-ref.

* g++.dg/tree-ssa/pr8781.C: Disable SRA.

From-SVN: r175916

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/pr8781.C
gcc/tree-ssa-sccvn.c

index 7a7326bd1b75ed133ee14c05666633a5cbcf3391..57c5390edeb2d4f113b72ebcc2aecda6395a1f43 100644 (file)
@@ -1,3 +1,15 @@
+2011-07-06  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/49645
+       * c-decl.c (finish_decl): Also set DECL_HARD_REGISTER for global
+       register variables.
+       * tree-ssa-sccvn.c (vn_reference_op_eq): Disregard differences
+       in type qualification here ...
+       (copy_reference_ops_from_ref): ... not here.
+       (vn_reference_lookup_3): ... or here.
+       (copy_reference_ops_from_ref): Record decl bases as MEM[&decl].
+       (vn_reference_lookup): Do the lookup with a valueized ao-ref.
+
 2011-07-06  Ian Lance Taylor  <iant@google.com>
 
        * doc/install.texi (Configuration): It's
index 357522b85fca10a86dc6a79f9274519441a0664b..3ed3c46e64c4d9598c8b0f52456a3ac2b7a6b1f2 100644 (file)
@@ -4357,6 +4357,8 @@ finish_decl (tree decl, location_t init_loc, tree init,
               when a tentative file-scope definition is seen.
               But at end of compilation, do output code for them.  */
            DECL_DEFER_OUTPUT (decl) = 1;
+         if (asmspec && C_DECL_REGISTER (decl))
+           DECL_HARD_REGISTER (decl) = 1;
          rest_of_decl_compilation (decl, true, 0);
        }
       else
index 99d804e118ec9f93a0c13510f9dcb67ce7a47361..d0254e65a4480f82b5aae5488f2e5b210edc4372 100644 (file)
@@ -1,3 +1,8 @@
+2011-07-06  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/49645
+       * g++.dg/tree-ssa/pr8781.C: Disable SRA.
+
 2011-07-06  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR middle-end/47383
index fc5f44394d9b42ae36d21ff27ae52c2d69d7ddce..cc518a0d25ae83d4a82b54810700132462b87bea 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O -fdump-tree-fre1-details" } */
+/* { dg-options "-O -fno-tree-sra -fdump-tree-fre1-details" } */
 
 int f();
 
index 8f96d6c0356da08b2fcfd556929b4dbaf3b16b6c..125d0444f4a72f523d95beb37b3e63213a4db938 100644 (file)
@@ -391,11 +391,15 @@ vn_reference_op_eq (const void *p1, const void *p2)
   const_vn_reference_op_t const vro1 = (const_vn_reference_op_t) p1;
   const_vn_reference_op_t const vro2 = (const_vn_reference_op_t) p2;
 
-  return vro1->opcode == vro2->opcode
-    && types_compatible_p (vro1->type, vro2->type)
-    && expressions_equal_p (vro1->op0, vro2->op0)
-    && expressions_equal_p (vro1->op1, vro2->op1)
-    && expressions_equal_p (vro1->op2, vro2->op2);
+  return (vro1->opcode == vro2->opcode
+         /* We do not care for differences in type qualification.  */
+         && (vro1->type == vro2->type
+             || (vro1->type && vro2->type
+                 && types_compatible_p (TYPE_MAIN_VARIANT (vro1->type),
+                                        TYPE_MAIN_VARIANT (vro2->type))))
+         && expressions_equal_p (vro1->op0, vro2->op0)
+         && expressions_equal_p (vro1->op1, vro2->op1)
+         && expressions_equal_p (vro1->op2, vro2->op2));
 }
 
 /* Compute the hash for a reference operand VRO1.  */
@@ -578,8 +582,7 @@ copy_reference_ops_from_ref (tree ref, VEC(vn_reference_op_s, heap) **result)
       vn_reference_op_s temp;
 
       memset (&temp, 0, sizeof (temp));
-      /* We do not care for spurious type qualifications.  */
-      temp.type = TYPE_MAIN_VARIANT (TREE_TYPE (ref));
+      temp.type = TREE_TYPE (ref);
       temp.opcode = TREE_CODE (ref);
       temp.op0 = TMR_INDEX (ref);
       temp.op1 = TMR_STEP (ref);
@@ -610,8 +613,7 @@ copy_reference_ops_from_ref (tree ref, VEC(vn_reference_op_s, heap) **result)
       vn_reference_op_s temp;
 
       memset (&temp, 0, sizeof (temp));
-      /* We do not care for spurious type qualifications.  */
-      temp.type = TYPE_MAIN_VARIANT (TREE_TYPE (ref));
+      temp.type = TREE_TYPE (ref);
       temp.opcode = TREE_CODE (ref);
       temp.off = -1;
 
@@ -676,16 +678,33 @@ copy_reference_ops_from_ref (tree ref, VEC(vn_reference_op_s, heap) **result)
                temp.off = off.low;
            }
          break;
+       case VAR_DECL:
+         if (DECL_HARD_REGISTER (ref))
+           {
+             temp.op0 = ref;
+             break;
+           }
+         /* Fallthru.  */
+       case PARM_DECL:
+       case CONST_DECL:
+       case RESULT_DECL:
+         /* Canonicalize decls to MEM[&decl] which is what we end up with
+            when valueizing MEM[ptr] with ptr = &decl.  */
+         temp.opcode = MEM_REF;
+         temp.op0 = build_int_cst (build_pointer_type (TREE_TYPE (ref)), 0);
+         temp.off = 0;
+         VEC_safe_push (vn_reference_op_s, heap, *result, &temp);
+         temp.opcode = ADDR_EXPR;
+         temp.op0 = build_fold_addr_expr (ref);
+         temp.type = TREE_TYPE (temp.op0);
+         temp.off = -1;
+         break;
        case STRING_CST:
        case INTEGER_CST:
        case COMPLEX_CST:
        case VECTOR_CST:
        case REAL_CST:
        case CONSTRUCTOR:
-       case VAR_DECL:
-       case PARM_DECL:
-       case CONST_DECL:
-       case RESULT_DECL:
        case SSA_NAME:
          temp.op0 = ref;
          break;
@@ -1580,7 +1599,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_)
       op.op0 = build_int_cst (ptr_type_node, at - rhs_offset);
       op.off = at - lhs_offset + rhs_offset;
       VEC_replace (vn_reference_op_s, vr->operands, 0, &op);
-      op.type = TYPE_MAIN_VARIANT (TREE_TYPE (rhs));
+      op.type = TREE_TYPE (rhs);
       op.opcode = TREE_CODE (rhs);
       op.op0 = rhs;
       op.off = -1;
@@ -1692,7 +1711,12 @@ vn_reference_lookup (tree op, tree vuse, vn_lookup_kind kind,
     {
       vn_reference_t wvnresult;
       ao_ref r;
-      ao_ref_init (&r, op);
+      /* Make sure to use a valueized reference ...  */
+      if (!ao_ref_init_from_vn_reference (&r, vr1.set, vr1.type, vr1.operands))
+       ao_ref_init (&r, op);
+      else
+       /* ... but also preserve a full reference tree for advanced TBAA.  */
+       r.ref = op;
       vn_walk_kind = kind;
       wvnresult =
        (vn_reference_t)walk_non_aliased_vuses (&r, vr1.vuse,