re PR tree-optimization/92891 (ice in decompose, at wide-int.h:984)
authorJakub Jelinek <jakub@redhat.com>
Tue, 10 Dec 2019 23:49:40 +0000 (00:49 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 10 Dec 2019 23:49:40 +0000 (00:49 +0100)
PR tree-optimization/92891
* builtins.c (gimple_call_alloc_size): Convert size to sizetype
before returning it.

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

From-SVN: r279205

gcc/ChangeLog
gcc/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr92891.c [new file with mode: 0644]

index c8ff6941d8fdde08c049556ccdd5eae070aaa5a5..fedf736bdab231387fe294fbe1dd316779a35140 100644 (file)
@@ -1,3 +1,9 @@
+2019-12-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/92891
+       * builtins.c (gimple_call_alloc_size): Convert size to sizetype
+       before returning it.
+
 2019-12-10  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR rtl-optimization/92796
index 53de17c105f996926add6fb4da549a87fdcd6145..205ac3927b923ba18aa83da2bb49bb660276d8e4 100644 (file)
@@ -3755,7 +3755,7 @@ gimple_call_alloc_size (gimple *stmt)
     return NULL_TREE;
 
   if (argidx2 > nargs && TREE_CODE (size) == INTEGER_CST)
-    return size;
+    return fold_convert (sizetype, size);
 
   /* To handle ranges do the math in wide_int and return the product
      of the upper bounds as a constant.  Ignore anti-ranges.  */
index 2ce9f6a38fd18e7c1e7803b2ebfde58b59ed4a6a..37de7de32f3051276cda01602bbe1bcde5af5434 100644 (file)
@@ -1,3 +1,8 @@
+2019-12-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/92891
+       * gcc.c-torture/compile/pr92891.c: New test.
+
 2019-12-10  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR rtl-optimization/92796
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr92891.c b/gcc/testsuite/gcc.c-torture/compile/pr92891.c
new file mode 100644 (file)
index 0000000..7490c90
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR tree-optimization/92891 */
+
+int a, b;
+char *foo (int) __attribute__((alloc_size(1)));
+
+void
+bar (void)
+{
+  char *e = foo (2);
+  while (a)
+    {
+      if (b <= 0)
+       continue;
+      e[b] = 0;
+    }
+}