public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-9752] middle-end/98726 - fix VECTOR_CST element access
@ 2021-04-23 9:10 Richard Sandiford
0 siblings, 0 replies; only message in thread
From: Richard Sandiford @ 2021-04-23 9:10 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:8849e4a94550ffc9a564c105f0cefed5f42b3a7d
commit r10-9752-g8849e4a94550ffc9a564c105f0cefed5f42b3a7d
Author: Richard Biener <rguenther@suse.de>
Date: Fri Apr 23 10:09:40 2021 +0100
middle-end/98726 - fix VECTOR_CST element access
This fixes VECTOR_CST element access with POLY_INT elements and
allows to produce dump files of the PR98726 testcase without
ICEing.
2021-04-23 Richard Biener <rguenther@suse.de>
PR middle-end/98726
* tree.h (vector_cst_int_elt): Remove.
* tree.c (vector_cst_int_elt): Use poly_wide_int for computations,
make static.
(cherry picked from commit 4b59dbb5d6759e43bfa23161a8d3feb9ae969e1a)
Diff:
---
gcc/tree.c | 10 +++++-----
gcc/tree.h | 1 -
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/gcc/tree.c b/gcc/tree.c
index 3c17694c703..b43bc809823 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -10982,13 +10982,13 @@ build_opaque_vector_type (tree innertype, poly_int64 nunits)
/* Return the value of element I of VECTOR_CST T as a wide_int. */
-wide_int
+static poly_wide_int
vector_cst_int_elt (const_tree t, unsigned int i)
{
/* First handle elements that are directly encoded. */
unsigned int encoded_nelts = vector_cst_encoded_nelts (t);
if (i < encoded_nelts)
- return wi::to_wide (VECTOR_CST_ENCODED_ELT (t, i));
+ return wi::to_poly_wide (VECTOR_CST_ENCODED_ELT (t, i));
/* Identify the pattern that contains element I and work out the index of
the last encoded element for that pattern. */
@@ -10999,13 +10999,13 @@ vector_cst_int_elt (const_tree t, unsigned int i)
/* If there are no steps, the final encoded value is the right one. */
if (!VECTOR_CST_STEPPED_P (t))
- return wi::to_wide (VECTOR_CST_ENCODED_ELT (t, final_i));
+ return wi::to_poly_wide (VECTOR_CST_ENCODED_ELT (t, final_i));
/* Otherwise work out the value from the last two encoded elements. */
tree v1 = VECTOR_CST_ENCODED_ELT (t, final_i - npatterns);
tree v2 = VECTOR_CST_ENCODED_ELT (t, final_i);
- wide_int diff = wi::to_wide (v2) - wi::to_wide (v1);
- return wi::to_wide (v2) + (count - 2) * diff;
+ poly_wide_int diff = wi::to_poly_wide (v2) - wi::to_poly_wide (v1);
+ return wi::to_poly_wide (v2) + (count - 2) * diff;
}
/* Return the value of element I of VECTOR_CST T. */
diff --git a/gcc/tree.h b/gcc/tree.h
index 328a2d5d226..bb80e81d389 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -4714,7 +4714,6 @@ extern tree first_field (const_tree);
extern bool initializer_zerop (const_tree, bool * = NULL);
extern bool initializer_each_zero_or_onep (const_tree);
-extern wide_int vector_cst_int_elt (const_tree, unsigned int);
extern tree vector_cst_elt (const_tree, unsigned int);
/* Given a vector VEC, return its first element if all elements are
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-23 9:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-23 9:10 [gcc r10-9752] middle-end/98726 - fix VECTOR_CST element access Richard Sandiford
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).