re PR middle-end/91725 (ICE in get_nonzero_bits starting with r275587)
authorJakub Jelinek <jakub@redhat.com>
Wed, 11 Sep 2019 08:33:55 +0000 (10:33 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 11 Sep 2019 08:33:55 +0000 (10:33 +0200)
PR middle-end/91725
* match.pd ((A / (1 << B)) -> (A >> B)): Call tree_nonzero_bits instead
of get_nonzero_bits, only call it for integral types.

* gcc.c-torture/compile/pr91725.c: New test.

From-SVN: r275633

gcc/ChangeLog
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr91725.c [new file with mode: 0644]

index 0aa93bceb4b887d69fa00c35f17dd375ff6f2b06..360e606f47e3685624c858364c54a4f79954c0ce 100644 (file)
@@ -1,3 +1,9 @@
+2019-09-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/91725
+       * match.pd ((A / (1 << B)) -> (A >> B)): Call tree_nonzero_bits instead
+       of get_nonzero_bits, only call it for integral types.
+
 2019-09-11  Richard Biener  <rguenther@suse.de>
 
        Revert
index 05009bb7a5ac8ded105fadb9e517b2a704d950a0..5690cf3d34905feaba1a7ba62d70db905163e29f 100644 (file)
@@ -325,9 +325,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
              && (TYPE_UNSIGNED (TREE_TYPE (@1))
                  || (element_precision (type)
                      == element_precision (TREE_TYPE (@1)))
-                 || (get_nonzero_bits (@0)
-                     & wi::mask (element_precision (TREE_TYPE (@1)) - 1, true,
-                                 element_precision (type))) == 0))))
+                 || (INTEGRAL_TYPE_P (type)
+                     && (tree_nonzero_bits (@0)
+                         & wi::mask (element_precision (TREE_TYPE (@1)) - 1,
+                                     true,
+                                     element_precision (type))) == 0)))))
   (rshift @0 @2)))
 
 /* Preserve explicit divisions by 0: the C++ front-end wants to detect
index 8b3dfbbecf00bc74aaa7910c9e5f9ed04e19031b..8ef80620c08a62de545bf7fc1830a0133be2c89e 100644 (file)
@@ -1,3 +1,8 @@
+2019-09-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/91725
+       * gcc.c-torture/compile/pr91725.c: New test.
+
 2019-09-11  Richard Biener  <rguenther@suse.de>
 
        Revert
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr91725.c b/gcc/testsuite/gcc.c-torture/compile/pr91725.c
new file mode 100644 (file)
index 0000000..f614a1c
--- /dev/null
@@ -0,0 +1,7 @@
+/* PR middle-end/91725 */
+
+unsigned long long
+foo (unsigned long long x, unsigned long long y, int z)
+{
+  return (x + y) / (1 << z);
+}