+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.
+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.
--- /dev/null
+/* 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" } } */
/* 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);
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);
/* 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);
}