tree-ssa-alias.c (collect_points_to_info_r): Handle pointing to PTR + OFFSET as PTR...
authorJakub Jelinek <jakub@redhat.com>
Sat, 11 Sep 2004 18:57:06 +0000 (20:57 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 11 Sep 2004 18:57:06 +0000 (20:57 +0200)
* tree-ssa-alias.c (collect_points_to_info_r): Handle
pointing to PTR + OFFSET as PTR, not as pointing to PTR or pointing
to OFFSET.

* gcc.dg/tree-ssa/20040911-1.c: New test.

From-SVN: r87357

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/20040911-1.c [new file with mode: 0644]
gcc/tree-ssa-alias.c

index 80d1437f0569029f9a4fc703440a68f0e31cf1a5..57e38175d5ec8546dd7aea888f9c4e9606e87c02 100644 (file)
@@ -1,3 +1,9 @@
+2004-09-11  Jakub Jelinek  <jakub@redhat.com>
+
+       * tree-ssa-alias.c (collect_points_to_info_r): Handle
+       pointing to PTR + OFFSET as PTR, not as pointing to PTR or pointing
+       to OFFSET.
+
 2004-09-11  Richard Henderson  <rth@redhat.com>
 
        * expr.c (expand_expr_addr_expr_1) Rename from expand_expr_addr_expr.
index 07cf16e8271e6896d8f2fae7eddda4b40825d8ff..3727d52ce4d8321e95b25b7efc4415c5b2f4881f 100644 (file)
@@ -1,3 +1,7 @@
+2004-09-11  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.dg/tree-ssa/20040911-1.c: New test.
+
 2004-09-11  Andreas Jaeger  <aj@suse.de>
 
        * gcc.c-torture/execute/991118-1.x: Delete, PR 16437 is fixed.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20040911-1.c b/gcc/testsuite/gcc.dg/tree-ssa/20040911-1.c
new file mode 100644 (file)
index 0000000..6b49570
--- /dev/null
@@ -0,0 +1,21 @@
+/* Verify that points-to information is handled properly for PTR + OFFSET
+   pointer arithmetics.  */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-alias1-vops" } */
+
+char buf[4], *q;
+int foo (int i)
+{
+  char c, *p;
+  q = &c;
+  p = buf;
+  if (i)
+    p = p + 3;
+  else
+    p = p + 2;
+  *p = 6;
+  c = 8;
+  return *p;
+}
+
+/* { dg-final { scan-tree-dump-not "VUSE <c" "alias1" } } */
index cd41fbae49ca631e2479c592e5693a08b236f7c9..47f8d96bc966cf0f66406bca0bdf35259bb37e7e 100644 (file)
@@ -1869,7 +1869,8 @@ collect_points_to_info_r (tree var, tree stmt, void *data)
            
            /* Both operands may be of pointer type.  FIXME: Shouldn't
               we just expect PTR + OFFSET always?  */
-           if (POINTER_TYPE_P (TREE_TYPE (op0)))
+           if (POINTER_TYPE_P (TREE_TYPE (op0))
+               && TREE_CODE (op0) != INTEGER_CST)
              {
                if (TREE_CODE (op0) == SSA_NAME)
                  merge_pointed_to_info (ai, var, op0);
@@ -1879,7 +1880,8 @@ collect_points_to_info_r (tree var, tree stmt, void *data)
                  add_pointed_to_expr (var, op0);
              }
 
-           if (POINTER_TYPE_P (TREE_TYPE (op1)))
+           if (POINTER_TYPE_P (TREE_TYPE (op1))
+               && TREE_CODE (op1) != INTEGER_CST)
              {
                if (TREE_CODE (op1) == SSA_NAME)
                  merge_pointed_to_info (ai, var, op1);
@@ -1892,8 +1894,10 @@ collect_points_to_info_r (tree var, tree stmt, void *data)
            /* Neither operand is a pointer?  VAR can be pointing
               anywhere.  FIXME: Is this right?  If we get here, we
               found PTR = INT_CST + INT_CST.  */
-           if (!POINTER_TYPE_P (TREE_TYPE (op0))
-               && !POINTER_TYPE_P (TREE_TYPE (op1)))
+           if (!(POINTER_TYPE_P (TREE_TYPE (op0))
+                 && TREE_CODE (op0) != INTEGER_CST)
+               && !(POINTER_TYPE_P (TREE_TYPE (op1))
+                    && TREE_CODE (op1) != INTEGER_CST))
              add_pointed_to_expr (var, rhs);
          }