public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Richard Biener <rguenther@suse.de>
Cc: Jonathan Wakely <jwakely@redhat.com>,
	Richard Sandiford <richard.sandiford@arm.com>,
	gcc-patches@gcc.gnu.org
Subject: [PATCH] use *_grow_cleared rather than *_grow on vect_unpromoted_value
Date: Fri, 29 Sep 2023 10:57:02 +0200	[thread overview]
Message-ID: <ZRaRXvGWkoPufmly@tucnak> (raw)
In-Reply-To: <nycvar.YFH.7.77.849.2309271105110.5561@jbgna.fhfr.qr>

[-- Attachment #1: Type: text/plain, Size: 1788 bytes --]

On Wed, Sep 27, 2023 at 11:15:26AM +0000, Richard Biener wrote:
> > tree-vect-patterns.cc:2947  unprom.quick_grow (nops);
> > T = vect_unpromoted_value
> > Go for quick_grow_cleared?  Something else?
> 
> The CTOR zero-initializes everything, so maybe it can go.  In theory
> .set_op could also be changed to .push_op ...

So, I had a look at this and I think using quick_grow_cleared is best choice
here.  The nops is 2 or 1 most of the time, worst case 3, so the price of
extra initialization of 4 pointer-sized-or-less members times 1, 2 or 3
doesn't seem worth bothering, it is similar to the bitmap_head case where
we already pay the price for just one structure anytime we do
  vect_unpromoted_value unprom_diff;
(and later set_op on it) or even
  vect_unpromoted_value unprom0[2];

With this patch and Richard S's poly_int_pod removal the static_assert can
be enabled as well and gcc builds.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

The second patch waits for the poly_int_pod removal commit and has been just
build tested but not bootstrapped yet.

2023-09-29  Jakub Jelinek  <jakub@redhat.com>

	* tree-vect-patterns.cc (vect_recog_over_widening_pattern): Use
	quick_grow_cleared method on unprom rather than quick_grow.

--- gcc/tree-vect-patterns.cc.jj	2023-08-24 15:37:29.321410276 +0200
+++ gcc/tree-vect-patterns.cc	2023-09-29 09:45:27.980168865 +0200
@@ -2944,7 +2944,7 @@ vect_recog_over_widening_pattern (vec_in
   /* Check the operands.  */
   unsigned int nops = gimple_num_ops (last_stmt) - first_op;
   auto_vec <vect_unpromoted_value, 3> unprom (nops);
-  unprom.quick_grow (nops);
+  unprom.quick_grow_cleared (nops);
   unsigned int min_precision = 0;
   bool single_use_p = false;
   for (unsigned int i = 0; i < nops; ++i)


	Jakub

[-- Attachment #2: Q017 --]
[-- Type: text/plain, Size: 536 bytes --]

2023-09-29  Jakub Jelinek  <jakub@redhat.com>

	* vec.h (quick_grow): Uncomment static_assert.

--- gcc/vec.h.jj	2023-09-29 10:39:09.327223861 +0200
+++ gcc/vec.h	2023-09-29 10:44:03.764108443 +0200
@@ -1396,7 +1396,7 @@ inline void
 vec<T, A, vl_embed>::quick_grow (unsigned len)
 {
   gcc_checking_assert (length () <= len && len <= m_vecpfx.m_alloc);
-//  static_assert (std::is_trivially_default_constructible <T>::value, "");
+  static_assert (std::is_trivially_default_constructible <T>::value, "");
   m_vecpfx.m_num = len;
 }
 

  reply	other threads:[~2023-09-29  8:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-27  5:03 [PATCH] vec.h: Make some ops work with non-trivially copy constructible and/or destructible types Jakub Jelinek
2023-09-27  7:17 ` Richard Biener
2023-09-27 10:46   ` [PATCH] vec.h, v2: " Jakub Jelinek
2023-09-27 11:15     ` Richard Biener
2023-09-29  8:57       ` Jakub Jelinek [this message]
2023-09-29  9:13         ` [PATCH] use *_grow_cleared rather than *_grow on vect_unpromoted_value Richard Biener
2023-09-27 13:15     ` [PATCH] vec.h, v2: Make some ops work with non-trivially copy constructible and/or destructible types Mikael Morin
2023-09-28  9:17     ` [PATCH] vec.h, v3: " Jakub Jelinek
2023-09-28  9:30       ` Richard Biener
2023-09-29 10:00       ` Jonathan Wakely
2023-09-29 10:07         ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZRaRXvGWkoPufmly@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --cc=rguenther@suse.de \
    --cc=richard.sandiford@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).