Skip to content

Commit 6f428f1

Browse files
juergenchristAndreas-Krebbel
authored andcommitted
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.
1 parent 1f7e5a7 commit 6f428f1

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

gcc/config/s390/s390.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7381,11 +7381,12 @@ s390_expand_vec_init (rtx target, rtx vals)
73817381
if (!general_operand (elem, GET_MODE (elem)))
73827382
elem = force_reg (inner_mode, elem);
73837383

7384-
emit_insn (gen_rtx_SET (target,
7385-
gen_rtx_UNSPEC (mode,
7386-
gen_rtvec (3, elem,
7387-
GEN_INT (i), target),
7388-
UNSPEC_VEC_SET)));
7384+
if (elem != const0_rtx)
7385+
emit_insn (gen_rtx_SET (target,
7386+
gen_rtx_UNSPEC (mode,
7387+
gen_rtvec (3, elem,
7388+
GEN_INT (i), target),
7389+
UNSPEC_VEC_SET)));
73897390
}
73907391
}
73917392

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* Check that the default case of the vec_init expander does its job. */
2+
3+
/* { dg-do compile } */
4+
/* { dg-options "-O3 -mzarch -march=z13" } */
5+
6+
typedef __attribute__((vector_size(16))) signed int v4si;
7+
8+
extern v4si G;
9+
10+
v4si
11+
n (signed int a)
12+
{
13+
return G == (v4si){ a };
14+
}
15+
/* { dg-final { scan-assembler-times "vzero" 1 } } */
16+
/* { dg-final { scan-assembler-times "vlvgf\t" 1 } } */
17+
/* { dg-final { scan-assembler-not "vleif\t" } } */

0 commit comments

Comments
 (0)