From 78930e4b4867c0558cf347778591a67a0b235ca0 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Mon, 18 Nov 2019 15:29:53 +0000 Subject: Add an empty constructor shortcut to build_vector_from_ctor Empty vector constructors are equivalent to zero vectors. If we handle that case directly, we can support it for variable-length vectors and can hopefully make things more efficient for fixed-length vectors. This is needed by a later C++ patch. 2019-11-18 Richard Sandiford gcc/ * tree.c (build_vector_from_ctor): Directly return a zero vector for empty constructors. From-SVN: r278413 --- gcc/ChangeLog | 5 +++++ gcc/tree.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4198461..be2fac7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2019-11-18 Richard Sandiford + * tree.c (build_vector_from_ctor): Directly return a zero vector for + empty constructors. + +2019-11-18 Richard Sandiford + * cse.c (cse_insn): Delete no-op register moves too. * simplify-rtx.c (comparison_to_mask): Handle unsigned comparisons. Take a second comparison to control the value for NE. diff --git a/gcc/tree.c b/gcc/tree.c index 4db3fa8..f9ea79d 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1858,6 +1858,9 @@ make_vector (unsigned log2_npatterns, tree build_vector_from_ctor (tree type, vec *v) { + if (vec_safe_length (v) == 0) + return build_zero_cst (type); + unsigned HOST_WIDE_INT idx, nelts; tree value; -- cgit v1.1