From 26ff85b0b9d79cbea0b75e727526d0dfbd4ec5dc Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 11 Jan 2016 20:06:34 +0100 Subject: [PATCH] re PR target/69071 (ICE: in decompose, at rtl.h:2107 with -g) PR target/69071 * lra-eliminations.c (move_plus_up): Only move plus up if subreg of the constant can be simplified into constant and use the simplified subreg of the constant instead of the original constant. * gcc.dg/pr69071.c: New test. From-SVN: r232241 --- gcc/ChangeLog | 6 ++++++ gcc/lra-eliminations.c | 11 ++++++++--- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.dg/pr69071.c | 22 ++++++++++++++++++++++ 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr69071.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5936b421c104..3d05c57c23df 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2016-01-11 Jakub Jelinek + PR target/69071 + * lra-eliminations.c (move_plus_up): Only move plus up + if subreg of the constant can be simplified into constant + and use the simplified subreg of the constant instead of + the original constant. + * fold-const.c (fold_convertible_p): Don't return true for conversion of VECTOR_TYPE to same sized integral type. (fold_convert_loc): Fix up formatting. Fold conversion of diff --git a/gcc/lra-eliminations.c b/gcc/lra-eliminations.c index ec9d7b717cf1..99d5c6f01716 100644 --- a/gcc/lra-eliminations.c +++ b/gcc/lra-eliminations.c @@ -296,9 +296,14 @@ move_plus_up (rtx x) if (GET_CODE (x) == SUBREG && GET_CODE (subreg_reg) == PLUS && GET_MODE_SIZE (x_mode) <= GET_MODE_SIZE (subreg_reg_mode) && CONSTANT_P (XEXP (subreg_reg, 1))) - return gen_rtx_PLUS (x_mode, lowpart_subreg (x_mode, subreg_reg, - subreg_reg_mode), - XEXP (subreg_reg, 1)); + { + rtx cst = simplify_subreg (x_mode, XEXP (subreg_reg, 1), subreg_reg_mode, + subreg_lowpart_offset (x_mode, + subreg_reg_mode)); + if (cst && CONSTANT_P (cst)) + return gen_rtx_PLUS (x_mode, lowpart_subreg (x_mode, subreg_reg, + subreg_reg_mode), cst); + } return x; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9e9423b520e7..aeea559dcbb0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2016-01-11 Jakub Jelinek + PR target/69071 + * gcc.dg/pr69071.c: New test. + PR c++/69211 * g++.dg/opt/pr69211.C: New test. diff --git a/gcc/testsuite/gcc.dg/pr69071.c b/gcc/testsuite/gcc.dg/pr69071.c new file mode 100644 index 000000000000..1a17a94808fb --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr69071.c @@ -0,0 +1,22 @@ +/* PR target/69071 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +void *bar (void *); + +void +foo (int c) +{ + unsigned char bf[65400]; + unsigned char *p2 = bar (bf); + unsigned char *p3 = bar (bf); + for (; *p2; p2++, c++) + { + if (c) + { + short of = p2 - bf - 6; + unsigned ofu = of; + __builtin_memcpy (p3, &ofu, sizeof (ofu)); + } + } +} -- 2.47.2