From a6ae300f9a019aff902cd11068af0956288d6541 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 11 Dec 2019 00:49:40 +0100 Subject: [PATCH] re PR tree-optimization/92891 (ice in decompose, at wide-int.h:984) 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 | 6 ++++++ gcc/builtins.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr92891.c | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr92891.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c8ff6941d8f..fedf736bdab 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-12-10 Jakub Jelinek + + PR tree-optimization/92891 + * builtins.c (gimple_call_alloc_size): Convert size to sizetype + before returning it. + 2019-12-10 Vladimir Makarov PR rtl-optimization/92796 diff --git a/gcc/builtins.c b/gcc/builtins.c index 53de17c105f..205ac3927b9 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2ce9f6a38fd..37de7de32f3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-12-10 Jakub Jelinek + + PR tree-optimization/92891 + * gcc.c-torture/compile/pr92891.c: New test. + 2019-12-10 Vladimir Makarov 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 index 00000000000..7490c90fb55 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr92891.c @@ -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; + } +} -- 2.30.2