OSDN Git Service

2014-05-06 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 May 2014 14:22:41 +0000 (14:22 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 May 2014 14:22:41 +0000 (14:22 +0000)
Backport from mainline
2013-05-27  Richard Biener  <rguenther@suse.de>

PR tree-optimization/57417
* tree-ssa-sccvn.c (set_ssa_val_to): Compare addresses using
get_addr_base_and_unit_offset.

* gcc.dg/torture/pr57417.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@210110 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr57417.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.c

index a5390e6..030f3ff 100644 (file)
@@ -1,3 +1,12 @@
+2014-05-06  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2013-05-27  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/57417
+       * tree-ssa-sccvn.c (set_ssa_val_to): Compare addresses using
+       get_addr_base_and_unit_offset.
+
 2014-04-25  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR target/60941
index e584545..6b5f1f5 100644 (file)
@@ -1,3 +1,11 @@
+2014-05-06  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2013-05-27  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/57417
+       * gcc.dg/torture/pr57417.c: New testcase.
+
 2014-04-25  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc.c-torture/execute/20140425-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/torture/pr57417.c b/gcc/testsuite/gcc.dg/torture/pr57417.c
new file mode 100644 (file)
index 0000000..6eac6f9
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+
+int a, b;
+volatile int *c;
+
+void foo ()
+{
+  volatile int d[1];
+  b = 0;
+  for (;; a--)
+    c = &d[b];
+}
index c2bd59d..1e4dc14 100644 (file)
@@ -2483,6 +2483,7 @@ static inline bool
 set_ssa_val_to (tree from, tree to)
 {
   tree currval = SSA_VAL (from);
+  HOST_WIDE_INT toff, coff;
 
   if (from != to)
     {
@@ -2518,7 +2519,17 @@ set_ssa_val_to (tree from, tree to)
       print_generic_expr (dump_file, to, 0);
     }
 
-  if (currval != to  && !operand_equal_p (currval, to, OEP_PURE_SAME))
+  if (currval != to
+      && !operand_equal_p (currval, to, OEP_PURE_SAME)
+      /* ???  For addresses involving volatile objects or types operand_equal_p
+        does not reliably detect ADDR_EXPRs as equal.  We know we are only
+        getting invariant gimple addresses here, so can use
+        get_addr_base_and_unit_offset to do this comparison.  */
+      && !(TREE_CODE (currval) == ADDR_EXPR
+          && TREE_CODE (to) == ADDR_EXPR
+          && (get_addr_base_and_unit_offset (TREE_OPERAND (currval, 0), &coff)
+              == get_addr_base_and_unit_offset (TREE_OPERAND (to, 0), &toff))
+          && coff == toff))
     {
       VN_INFO (from)->valnum = to;
       if (dump_file && (dump_flags & TDF_DETAILS))