]> gcc.gnu.org Git - gcc.git/commit
fold-const: Fix up fold_read_from_vector [PR100887]
authorJakub Jelinek <jakub@redhat.com>
Mon, 7 Jun 2021 07:28:31 +0000 (09:28 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 17 Jun 2021 05:58:25 +0000 (07:58 +0200)
commitce1dd5e70514fde8e34c86ab45a3c55e84d3c5b7
treeeeee6cb7851f95906a856a1b1b2e386c493dc799
parentd9f75e8a73b1b69b8f709b56296b4a9751c50ef0
fold-const: Fix up fold_read_from_vector [PR100887]

The callers of fold_read_from_vector expect that the index they pass is
an index of an element in the vector and the function does that most of the
time.  But we allow CONSTRUCTORs with VECTOR_TYPE to have VECTOR_TYPE
elements and in that case every CONSTRUCTOR element represents not just one
index (with the exception of V1 vectors), but multiple.
So returning zero vector if i >= CONSTRUCTOR_NELTS or returning some
CONSTRUCTOR_ELT's value might not be what the callers expect.

Fixed by punting if the first element has vector type.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

In theory we could instead recurse (and assert that for CONSTRUCTORs of
vector elements we have always all elements specified like tree-cfg.c
verifies?) after adjusting the index appropriately.

2021-06-07  Jakub Jelinek  <jakub@redhat.com>

PR target/100887
* fold-const.c (fold_read_from_vector): Return NULL if trying to
read from a CONSTRUCTOR with vector type elements.

(cherry picked from commit e1521b170b44be5cd5d36a98b6b760457b68f566)
gcc/fold-const.c
This page took 0.065575 seconds and 5 git commands to generate.