Let tree_single_nonzero_warnv_p use range information
authorMarc Glisse <marc.glisse@inria.fr>
Tue, 25 Apr 2017 06:51:44 +0000 (08:51 +0200)
committerMarc Glisse <glisse@gcc.gnu.org>
Tue, 25 Apr 2017 06:51:44 +0000 (06:51 +0000)
2017-04-25  Marc Glisse  <marc.glisse@inria.fr>

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
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wstrict-overflow-18.c
gcc/testsuite/gcc.dg/tree-ssa/cmpmul-1.c [new file with mode: 0644]

index 95bb4152c2593247ee892260c3a7af0c2035c51f..5b59d793850f6cc3068095627cc3fe4366f2fb5c 100644 (file)
@@ -1,3 +1,7 @@
+2017-04-25  Marc Glisse  <marc.glisse@inria.fr>
+
+       * fold-const.c (tree_single_nonzero_warnv_p): Handle SSA_NAME.
+
 2017-04-25  Julian Brown  <julian@codesourcery.com>
            Naveen H.S  <Naveen.Hurugalawadi@cavium.com>
 
index 4ae21fb0d2ff8ca5f7599982e7bb43fdb5b4bde1..f0b8e7a3f1b6227416074733aba533f709ddaf60 100644 (file)
@@ -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;
     }
index 824a8a11f0e84ccec64f21ca499f6e19983feadc..4fb111ebe904f0206a9e97ea4f8a815f8cc17da5 100644 (file)
@@ -1,3 +1,8 @@
+2017-04-25  Marc Glisse  <marc.glisse@inria.fr>
+
+       * gcc.dg/tree-ssa/cmpmul-1.c: New file.
+       * gcc.dg/Wstrict-overflow-18.c: Xfail.
+
 2017-04-22  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/80121
index bab91ce38895b2ead0fb264f339409d3e64c4cd0..8c8ddcf2b26ec6c8285a0cf6a8be814d6e7055d4 100644 (file)
@@ -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 (file)
index 0000000..1e303b1
--- /dev/null
@@ -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" } } */