public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Relax vector_builder::elt sanity check
@ 2019-07-12  7:55 Richard Sandiford
  2019-07-12 10:08 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Sandiford @ 2019-07-12  7:55 UTC (permalink / raw)
  To: gcc-patches

I'd made it a precondition of vector_builder::elt that the encoding
must have been fully populated and that all implicit elements are
therefore defined.  But for one of the AArch64 patches I'm working on,
it'd be convenient to be able to look back at previous elements while
building up the encoding.  This patch therefore makes the assert
specific to implicit elements only.

Tested on aarch64-linux-gnu, aarch64_be-elf and x86_64-linux-gnu.
OK to install?

Richard


2019-07-12  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* vector-builder.h (vector_builder::elt): Allow already-supplied
	elements to be read back before building is complete.

Index: gcc/vector-builder.h
===================================================================
--- gcc/vector-builder.h	2019-07-12 08:39:56.000000000 +0100
+++ gcc/vector-builder.h	2019-07-12 08:46:38.069172474 +0100
@@ -199,14 +199,15 @@ vector_builder<T, Derived>::operator ==
 T
 vector_builder<T, Derived>::elt (unsigned int i) const
 {
-  /* This only makes sense if the encoding has been fully populated.  */
-  gcc_checking_assert (encoded_nelts () <= this->length ());
-
   /* First handle elements that are already present in the underlying
      vector, regardless of whether they're part of the encoding or not.  */
   if (i < this->length ())
     return (*this)[i];
 
+  /* Extrapolation is only possible if the encoding has been fully
+     populated.  */
+  gcc_checking_assert (encoded_nelts () <= this->length ());
+
   /* Identify the pattern that contains element I and work out the index of
      the last encoded element for that pattern.  */
   unsigned int pattern = i % m_npatterns;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Relax vector_builder::elt sanity check
  2019-07-12  7:55 Relax vector_builder::elt sanity check Richard Sandiford
@ 2019-07-12 10:08 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2019-07-12 10:08 UTC (permalink / raw)
  To: GCC Patches, Richard Sandiford

On Fri, Jul 12, 2019 at 9:49 AM Richard Sandiford
<richard.sandiford@arm.com> wrote:
>
> I'd made it a precondition of vector_builder::elt that the encoding
> must have been fully populated and that all implicit elements are
> therefore defined.  But for one of the AArch64 patches I'm working on,
> it'd be convenient to be able to look back at previous elements while
> building up the encoding.  This patch therefore makes the assert
> specific to implicit elements only.
>
> Tested on aarch64-linux-gnu, aarch64_be-elf and x86_64-linux-gnu.
> OK to install?

OK.

> Richard
>
>
> 2019-07-12  Richard Sandiford  <richard.sandiford@arm.com>
>
> gcc/
>         * vector-builder.h (vector_builder::elt): Allow already-supplied
>         elements to be read back before building is complete.
>
> Index: gcc/vector-builder.h
> ===================================================================
> --- gcc/vector-builder.h        2019-07-12 08:39:56.000000000 +0100
> +++ gcc/vector-builder.h        2019-07-12 08:46:38.069172474 +0100
> @@ -199,14 +199,15 @@ vector_builder<T, Derived>::operator ==
>  T
>  vector_builder<T, Derived>::elt (unsigned int i) const
>  {
> -  /* This only makes sense if the encoding has been fully populated.  */
> -  gcc_checking_assert (encoded_nelts () <= this->length ());
> -
>    /* First handle elements that are already present in the underlying
>       vector, regardless of whether they're part of the encoding or not.  */
>    if (i < this->length ())
>      return (*this)[i];
>
> +  /* Extrapolation is only possible if the encoding has been fully
> +     populated.  */
> +  gcc_checking_assert (encoded_nelts () <= this->length ());
> +
>    /* Identify the pattern that contains element I and work out the index of
>       the last encoded element for that pattern.  */
>    unsigned int pattern = i % m_npatterns;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-12 10:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-12  7:55 Relax vector_builder::elt sanity check Richard Sandiford
2019-07-12 10:08 ` Richard Biener

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).