From: Andreas Krebbel Date: Mon, 15 Oct 2018 08:07:13 +0000 (+0000) Subject: S/390: Fix problem with vec_init expander X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cab5fe166dd13e1668801f00189459d3139a9342;p=gcc.git S/390: Fix problem with vec_init expander gcc/ChangeLog: 2018-10-15 Andreas Krebbel * config/s390/s390.c (s390_expand_vec_init): Force vector element into reg if it isn't a general operand. gcc/testsuite/ChangeLog: 2018-10-15 Andreas Krebbel * g++.dg/vec-init-1.C: New test. From-SVN: r265158 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8144181a567..4f33576c125 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-10-15 Andreas Krebbel + + * config/s390/s390.c (s390_expand_vec_init): Force vector element + into reg if it isn't a general operand. + 2018-10-14 H.J. Lu PR target/87599 diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 71039fe6ce9..ab22c2c8be5 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -6627,11 +6627,16 @@ s390_expand_vec_init (rtx target, rtx vals) return; } + /* Use vector replicate instructions. vlrep/vrepi/vrep */ if (all_same) { - emit_insn (gen_rtx_SET (target, - gen_rtx_VEC_DUPLICATE (mode, - XVECEXP (vals, 0, 0)))); + rtx elem = XVECEXP (vals, 0, 0); + + /* vec_splats accepts general_operand as source. */ + if (!general_operand (elem, GET_MODE (elem))) + elem = force_reg (inner_mode, elem); + + emit_insn (gen_rtx_SET (target, gen_rtx_VEC_DUPLICATE (mode, elem))); return; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8824474e85d..f12a7437d1d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-10-15 Andreas Krebbel + + * g++.dg/vec-init-1.C: New test. + 2018-10-14 H.J. Lu PR target/87599 diff --git a/gcc/testsuite/g++.dg/vec-init-1.C b/gcc/testsuite/g++.dg/vec-init-1.C new file mode 100644 index 00000000000..f35d39c35ed --- /dev/null +++ b/gcc/testsuite/g++.dg/vec-init-1.C @@ -0,0 +1,26 @@ +/* On S/390 this ends up calling the vec_init RTL expander with a + parallel of two symbol_refs. */ + +/* { dg-do compile } */ +/* { dg-options "-O3 -fPIC" } */ + + +struct test +{ + struct base + { + int key; + }; + struct derived : public base + { + int key; + }; + + derived core; + derived &dRef; + base &bRef; + + test() : dRef (core), bRef (core) {} +}; + +test test;