From bb0249cbb7500772af1bfcc68f8929d60f6cb51f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 25 Apr 2017 08:51:44 +0200 Subject: [PATCH] Let tree_single_nonzero_warnv_p use range information 2017-04-25 Marc Glisse gcc/ * fold-const.c (tree_single_nonzero_warnv_p): Handle SSA_NAME. gcc/testsuite/ * gcc.dg/tree-ssa/cmpmul-1.c: New file. * gcc.dg/Wstrict-overflow-18.c: Xfail. From-SVN: r247123 --- gcc/ChangeLog | 4 ++++ gcc/fold-const.c | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/Wstrict-overflow-18.c | 3 ++- gcc/testsuite/gcc.dg/tree-ssa/cmpmul-1.c | 11 +++++++++++ 5 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/cmpmul-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 95bb4152c25..5b59d793850 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2017-04-25 Marc Glisse + + * fold-const.c (tree_single_nonzero_warnv_p): Handle SSA_NAME. + 2017-04-25 Julian Brown Naveen H.S diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 4ae21fb0d2f..f0b8e7a3f1b 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -13412,6 +13412,11 @@ tree_single_nonzero_warnv_p (tree t, bool *strict_overflow_p) } break; + case SSA_NAME: + if (!INTEGRAL_TYPE_P (TREE_TYPE (t))) + break; + return expr_not_equal_to (t, wi::zero (TYPE_PRECISION (TREE_TYPE (t)))); + default: break; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 824a8a11f0e..4fb111ebe90 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-04-25 Marc Glisse + + * gcc.dg/tree-ssa/cmpmul-1.c: New file. + * gcc.dg/Wstrict-overflow-18.c: Xfail. + 2017-04-22 Janus Weil PR fortran/80121 diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-18.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-18.c index bab91ce3889..8c8ddcf2b26 100644 --- a/gcc/testsuite/gcc.dg/Wstrict-overflow-18.c +++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-18.c @@ -14,7 +14,8 @@ foo (struct c *p) for (i = 0; i < p->a - p->b; ++i) { - if (i > 0) /* { dg-warning "signed overflow" "" } */ + /* See PR80511 for the XFAIL. */ + if (i > 0) /* { dg-warning "signed overflow" "" { xfail *-*-* } } */ sum += 2; bar (p); } diff --git a/gcc/testsuite/gcc.dg/tree-ssa/cmpmul-1.c b/gcc/testsuite/gcc.dg/tree-ssa/cmpmul-1.c new file mode 100644 index 00000000000..1e303b19690 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/cmpmul-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized-raw" } */ + +int f(int a, int b, int c){ + c |= 1; // c cannot be 0 + a *= c; + b *= c; + return a == b; +} + +/* { dg-final { scan-tree-dump-not "bit_ior_expr" "optimized" } } */ -- 2.30.2