From 852e7df70a206715ad328ceb4c0f2282906c24d0 Mon Sep 17 00:00:00 2001 From: jakub Date: Fri, 15 Jun 2018 20:36:38 +0000 Subject: [PATCH] PR middle-end/85878 * expr.c (expand_assignment): Remove now redundant COMPLEX_MODE_P check from first store_expr, use to_mode instead of GET_MODE (to_rtx). Only call store_expr for halves if the mode is the same. * gfortran.fortran-torture/compile/pr85878.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@261659 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/expr.c | 6 +++--- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gfortran.fortran-torture/compile/pr85878.f90 | 8 ++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.fortran-torture/compile/pr85878.f90 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9c7c574c762..d3f322de367 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2018-06-15 Jakub Jelinek + PR middle-end/85878 + * expr.c (expand_assignment): Remove now redundant COMPLEX_MODE_P + check from first store_expr, use to_mode instead of GET_MODE (to_rtx). + Only call store_expr for halves if the mode is the same. + PR middle-end/86123 * match.pd ((X / Y) == 0 -> X < Y): Don't transform complex divisions. Fix up comment formatting. diff --git a/gcc/expr.c b/gcc/expr.c index d6b3eb4530a..793b283842a 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -5150,12 +5150,12 @@ expand_assignment (tree to, tree from, bool nontemporal) gcc_checking_assert (COMPLEX_MODE_P (to_mode)); poly_int64 mode_bitsize = GET_MODE_BITSIZE (to_mode); unsigned short inner_bitsize = GET_MODE_UNIT_BITSIZE (to_mode); - if (TYPE_MODE (TREE_TYPE (from)) == GET_MODE (to_rtx) - && COMPLEX_MODE_P (GET_MODE (to_rtx)) + if (TYPE_MODE (TREE_TYPE (from)) == to_mode && known_eq (bitpos, 0) && known_eq (bitsize, mode_bitsize)) result = store_expr (from, to_rtx, false, nontemporal, reversep); - else if (known_eq (bitsize, inner_bitsize) + else if (TYPE_MODE (TREE_TYPE (from)) == GET_MODE_INNER (to_mode) + && known_eq (bitsize, inner_bitsize) && (known_eq (bitpos, 0) || known_eq (bitpos, inner_bitsize))) result = store_expr (from, XEXP (to_rtx, maybe_ne (bitpos, 0)), diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 045c4cd6849..89b05676f50 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-06-15 Jakub Jelinek + PR middle-end/85878 + * gfortran.fortran-torture/compile/pr85878.f90: New test. + PR middle-end/86123 * gcc.c-torture/compile/pr86123.c: New test. diff --git a/gcc/testsuite/gfortran.fortran-torture/compile/pr85878.f90 b/gcc/testsuite/gfortran.fortran-torture/compile/pr85878.f90 new file mode 100644 index 00000000000..e52e95faa00 --- /dev/null +++ b/gcc/testsuite/gfortran.fortran-torture/compile/pr85878.f90 @@ -0,0 +1,8 @@ +! PR middle-end/85878 + +program pr85878 + real :: a + complex :: c = (2.0, 3.0) + print *, c + print *, transfer (a, c) +end -- 2.11.4.GIT