From 6f428f1a88557f8b5df653ece92ac3e7b5baf6c6 Mon Sep 17 00:00:00 2001 From: Juergen Christ Date: Fri, 7 Jul 2023 16:52:22 +0200 Subject: IBM Z: Fix vec_init default expander Do not reinitialize vector lanes to zero since they are already initialized to zero. gcc/ChangeLog: * config/s390/s390.cc (vec_init): Fix default case gcc/testsuite/ChangeLog: * gcc.target/s390/vector/vec-init-3.c: New test. --- gcc/config/s390/s390.cc | 11 ++++++----- gcc/testsuite/gcc.target/s390/vector/vec-init-3.c | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.target/s390/vector/vec-init-3.c (limited to 'gcc') diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index d9f10542..13970ed 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -7381,11 +7381,12 @@ s390_expand_vec_init (rtx target, rtx vals) if (!general_operand (elem, GET_MODE (elem))) elem = force_reg (inner_mode, elem); - emit_insn (gen_rtx_SET (target, - gen_rtx_UNSPEC (mode, - gen_rtvec (3, elem, - GEN_INT (i), target), - UNSPEC_VEC_SET))); + if (elem != const0_rtx) + emit_insn (gen_rtx_SET (target, + gen_rtx_UNSPEC (mode, + gen_rtvec (3, elem, + GEN_INT (i), target), + UNSPEC_VEC_SET))); } } diff --git a/gcc/testsuite/gcc.target/s390/vector/vec-init-3.c b/gcc/testsuite/gcc.target/s390/vector/vec-init-3.c new file mode 100644 index 0000000..12008a9 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/vector/vec-init-3.c @@ -0,0 +1,17 @@ +/* Check that the default case of the vec_init expander does its job. */ + +/* { dg-do compile } */ +/* { dg-options "-O3 -mzarch -march=z13" } */ + +typedef __attribute__((vector_size(16))) signed int v4si; + +extern v4si G; + +v4si +n (signed int a) +{ + return G == (v4si){ a }; +} +/* { dg-final { scan-assembler-times "vzero" 1 } } */ +/* { dg-final { scan-assembler-times "vlvgf\t" 1 } } */ +/* { dg-final { scan-assembler-not "vleif\t" } } */ -- cgit v1.1