From e54675bbabc2ed8100b7055008818b391cbbabbb Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 22 Nov 2017 17:44:46 +0100 Subject: [PATCH] Avoid two_valued_val_range_p for pointers. 2017-11-22 Marc Glisse PR tree-optimization/83104 gcc/ * vr-values.c (simplify_stmt_using_ranges): Check integral argument, not result. gcc/testsuite/ * gcc.c-torture/compile/pr83104.c: New file. From-SVN: r255068 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr83104.c | 5 +++++ gcc/vr-values.c | 2 +- 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr83104.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4b248cd81b7..f80012097ca 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-11-22 Marc Glisse + + PR tree-optimization/83104 + * vr-values.c (simplify_stmt_using_ranges): Check integral argument, + not result. + 2017-11-22 Marek Polacek H.J. Lu Jason Merrill diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7dbdc24292c..737424b1fd9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-11-22 Marc Glisse + + PR tree-optimization/83104 + * gcc.c-torture/compile/pr83104.c: New file. + 2017-11-22 Christophe Lyon * gcc.target/arm/pr56184.C: Add -Wno-return-type to dg-options. diff --git a/gcc/testsuite/gcc.c-torture/compile/pr83104.c b/gcc/testsuite/gcc.c-torture/compile/pr83104.c new file mode 100644 index 00000000000..40dc3d4da43 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr83104.c @@ -0,0 +1,5 @@ +int *a; +int foo() { + if (a && a - (int *)0 > 0) + return 0; +} diff --git a/gcc/vr-values.c b/gcc/vr-values.c index 7b9c5ad6c4b..0150f59d53d 100644 --- a/gcc/vr-values.c +++ b/gcc/vr-values.c @@ -4091,7 +4091,7 @@ vr_values::simplify_stmt_using_ranges (gimple_stmt_iterator *gsi) LHS = VAR == VAL1 ? (VAL1 BINOP CST) : (VAL2 BINOP CST) */ if (TREE_CODE_CLASS (rhs_code) == tcc_binary - && INTEGRAL_TYPE_P (TREE_TYPE (lhs)) + && INTEGRAL_TYPE_P (TREE_TYPE (rhs1)) && ((TREE_CODE (rhs1) == INTEGER_CST && TREE_CODE (rhs2) == SSA_NAME) || (TREE_CODE (rhs2) == INTEGER_CST -- 2.30.2