From 11522353fe7d3490ecf2877879bd2978b2277926 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 24 Jul 2008 04:51:12 +0000 Subject: [PATCH] tree-vrp.c (infer_value_range): Ignore asm statements when looking for memory accesses for... ./: * tree-vrp.c (infer_value_range): Ignore asm statements when looking for memory accesses for -fdelete-null-pointer-checks. testsuite/: * gcc.target/i386/20080723-1.c: New test. From-SVN: r138107 --- gcc/ChangeLog | 5 +++ gcc/testsuite/ChangeLog | 4 ++ gcc/testsuite/gcc.target/i386/20080723-1.c | 49 ++++++++++++++++++++++ gcc/tree-vrp.c | 4 +- 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/20080723-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 82c7e61e39c..b032c85bbac 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2008-07-23 Ian Lance Taylor + + * tree-vrp.c (infer_value_range): Ignore asm statements when + looking for memory accesses for -fdelete-null-pointer-checks. + 2008-07-24 Ben Elliston * config/spu/spu-c.c (__vector_keyword): New variable. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5be864f133f..f4d271c3e17 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-07-23 Ian Lance Taylor + + * gcc.target/i386/20080723-1.c: New test. + 2008-07-24 Ben Elliston * gcc.target/spu/vector.c: New test. diff --git a/gcc/testsuite/gcc.target/i386/20080723-1.c b/gcc/testsuite/gcc.target/i386/20080723-1.c new file mode 100644 index 00000000000..a2ed5bf86df --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/20080723-1.c @@ -0,0 +1,49 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); +extern void exit (int); + +static inline __attribute__((always_inline)) +void +prefetch (void *x) +{ + asm volatile("prefetcht0 %0" : : "m" (*(unsigned long *)x)); +} + +struct hlist_head +{ + struct hlist_node *first; +}; + +struct hlist_node +{ + struct hlist_node *next; + unsigned long i_ino; +}; + +struct hlist_node * find_inode_fast(struct hlist_head *head, unsigned long ino) +{ + struct hlist_node *node; + + for (node = head->first; + node && (prefetch (node->next), 1); + node = node->next) + { + if (node->i_ino == ino) + break; + } + return node ? node : 0; +} + +struct hlist_node g2; +struct hlist_node g1 = { &g2 }; +struct hlist_head h = { &g1 }; + +int +main() +{ + if (find_inode_fast (&h, 1) != 0) + abort (); + exit (0); +} diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 404531f4504..62f314795ae 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -3456,7 +3456,9 @@ infer_value_range (tree stmt, tree op, enum tree_code *comp_code_p, tree *val_p) /* We can only assume that a pointer dereference will yield non-NULL if -fdelete-null-pointer-checks is enabled. */ - if (flag_delete_null_pointer_checks && POINTER_TYPE_P (TREE_TYPE (op))) + if (flag_delete_null_pointer_checks + && POINTER_TYPE_P (TREE_TYPE (op)) + && TREE_CODE (stmt) != ASM_EXPR) { unsigned num_uses, num_loads, num_stores; -- 2.30.2