From: Jakub Jelinek Date: Fri, 30 Aug 2019 12:02:02 +0000 (+0200) Subject: backport: re PR tree-optimization/89278 (ICE in gimplify_modify_expr, at gimplify... X-Git-Tag: releases/gcc-7.5.0~250 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b84dee85b958bb342a205a23a34c6447df707ad6;p=thirdparty%2Fgcc.git backport: re PR tree-optimization/89278 (ICE in gimplify_modify_expr, at gimplify.c:5821) Backported from mainline 2019-02-15 Richard Biener Jakub Jelinek PR tree-optimization/89278 * tree-loop-distribution.c: Include tree-eh.h. (generate_memset_builtin, generate_memcpy_builtin): Call rewrite_to_non_trapping_overflow on builtin->size before passing it to force_gimple_operand_gsi. * gcc.dg/pr89278.c: New test. From-SVN: r275113 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d00c11b5d6b6..4bec5f5c6e64 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,15 @@ 2019-08-30 Jakub Jelinek Backported from mainline + 2019-02-15 Richard Biener + Jakub Jelinek + + PR tree-optimization/89278 + * tree-loop-distribution.c: Include tree-eh.h. + (generate_memset_builtin, generate_memcpy_builtin): Call + rewrite_to_non_trapping_overflow on builtin->size before passing it + to force_gimple_operand_gsi. + 2019-02-15 Jakub Jelinek PR other/89342 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c83e4bfd021c..86a8d1c412f1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,12 @@ 2019-08-30 Jakub Jelinek Backported from mainline + 2019-02-15 Richard Biener + Jakub Jelinek + + PR tree-optimization/89278 + * gcc.dg/pr89278.c: New test. + 2019-02-15 Jakub Jelinek PR other/89342 diff --git a/gcc/testsuite/gcc.dg/pr89278.c b/gcc/testsuite/gcc.dg/pr89278.c new file mode 100644 index 000000000000..609cb1a53a99 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr89278.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/89278 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftrapv -ftree-loop-distribute-patterns --param max-loop-header-insns=2" } */ + +void +foo (int *w, int x, int y, int z) +{ + while (x < y + z) + { + w[x] = 0; + ++x; + } +} + +void +bar (int *__restrict u, int *__restrict w, int x, int y, int z) +{ + while (x < y + z) + { + w[x] = u[x]; + ++x; + } +} diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index 1b9950eca8ee..c8e9db81448b 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -64,6 +64,7 @@ along with GCC; see the file COPYING3. If not see #include "cfgloop.h" #include "tree-scalar-evolution.h" #include "tree-vectorizer.h" +#include "tree-eh.h" /* A Reduced Dependence Graph (RDG) vertex representing a statement. */ @@ -815,6 +816,7 @@ generate_memset_builtin (struct loop *loop, partition *partition) nb_bytes = build_size_arg_loc (loc, partition->main_dr, partition->niter, partition->plus_one); + nb_bytes = rewrite_to_non_trapping_overflow (nb_bytes); nb_bytes = force_gimple_operand_gsi (&gsi, nb_bytes, true, NULL_TREE, false, GSI_CONTINUE_LINKING); mem = build_addr_arg_loc (loc, partition->main_dr, nb_bytes); @@ -871,6 +873,7 @@ generate_memcpy_builtin (struct loop *loop, partition *partition) nb_bytes = build_size_arg_loc (loc, partition->main_dr, partition->niter, partition->plus_one); + nb_bytes = rewrite_to_non_trapping_overflow (nb_bytes); nb_bytes = force_gimple_operand_gsi (&gsi, nb_bytes, true, NULL_TREE, false, GSI_CONTINUE_LINKING); dest = build_addr_arg_loc (loc, partition->main_dr, nb_bytes);