From 6261ab0ee61da61460b541fd877d741f3b8dbd05 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Wed, 16 Mar 2011 11:32:58 -0600 Subject: [PATCH] tree-vrp.c (identify_jump_threads): Slightly simplify type check for operands of conditional. * tree-vrp.c (identify_jump_threads): Slightly simplify type check for operands of conditional. Allow type to be a pointer. * gcc.dg/tree-ssa/vrp55.c: New test. From-SVN: r171055 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/tree-ssa/vrp55.c | 14 ++++++++++++++ gcc/tree-vrp.c | 10 ++++++---- 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/vrp55.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c19efcb5d9f..faf65fc4eb9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-03-16 Jeff Law + + * tree-vrp.c (identify_jump_threads): Slightly simplify type + check for operands of conditional. Allow type to be a + pointer. + 2011-03-16 Richard Guenther PR tree-optimization/48149 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 649dc4c61f8..72f30d8215a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-03-16 Jeff Law + + * gcc.dg/tree-ssa/vrp55.c: New test. + 2011-03-16 Jason Merrill * g++.dg/cpp0x/auto22.C: New. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp55.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp55.c new file mode 100644 index 00000000000..7adfe62052d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp55.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-vrp1-blocks-vops-details" } */ + +fu (char *p, int x) +{ + if (x) + *p = 69; + if (p) + arf (); +} + +/* { dg-final { scan-tree-dump-times "Threaded jump" 1 "vrp1" } } */ +/* { dg-final { cleanup-tree-dump "vrp1" } } */ + diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 65d249f9ae2..d2e6551d992 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -7538,12 +7538,14 @@ identify_jump_threads (void) continue; /* We're basically looking for any kind of conditional with - integral type arguments. */ + integral or pointer type arguments. Note the type of the second + argument will be the same as the first argument, so no need to + check it explicitly. */ if (TREE_CODE (gimple_cond_lhs (last)) == SSA_NAME - && INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_lhs (last))) + && (INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_lhs (last))) + || POINTER_TYPE_P (TREE_TYPE (gimple_cond_lhs (last)))) && (TREE_CODE (gimple_cond_rhs (last)) == SSA_NAME - || is_gimple_min_invariant (gimple_cond_rhs (last))) - && INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_rhs (last)))) + || is_gimple_min_invariant (gimple_cond_rhs (last)))) { edge_iterator ei; -- 2.30.2