From: Marc Glisse Date: Tue, 25 Apr 2017 06:51:44 +0000 (+0200) Subject: Let tree_single_nonzero_warnv_p use range information X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bb0249cbb7500772af1bfcc68f8929d60f6cb51f;p=gcc.git 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 --- 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" } } */