]> git.ipfire.org Git - thirdparty/gcc.git/commit
vect: Fix wrong shift_n after widening on BE [PR107338]
authorKewen Lin <linkw@linux.ibm.com>
Tue, 25 Oct 2022 05:18:08 +0000 (00:18 -0500)
committerKewen Lin <linkw@linux.ibm.com>
Tue, 25 Oct 2022 05:18:08 +0000 (00:18 -0500)
commit958014f369c8817184af110f8eb2c433a712fd0a
tree622861233e1174cd9b8118e1b1a673d5ce7ae961
parent5a20a4705c960ac323d1fe25f766e1204e0c98bd
vect: Fix wrong shift_n after widening on BE [PR107338]

As PR107338 shows, with the use of widening loads, the
container_type can become a wider type, it causes us to
get wrong shift_n since the BIT_FIELD_REF offset actually
becomes bigger on BE.  Taking the case in PR107338 as
example, at the beginning the container type is short and
BIT_FIELD_REF offset is 8 and size is 4, with unpacking to
wider type int, the high 16 bits are zero, by viewing it
as type int, its offset actually becomes to 24.  So the
shift_n should be 4 (32 - 24 - 4) instead of 20 (32 - 8
- 4).

I noticed that if we move shift_n calculation early
before the adjustments for widening loads (container type
change), it's based on all the stuffs of the original
container, the shfit_n calculated there is exactly what
we want, it can be independent of widening.  Besides, I
add prec adjustment together with the current adjustments
for widening loads, although prec's subsequent uses don't
require this change for now, since the container type gets
changed, we should keep the corresponding prec consistent.

PR tree-optimization/107338

gcc/ChangeLog:

* tree-vect-patterns.cc (vect_recog_bitfield_ref_pattern): Move
shfit_n calculation before the adjustments for widening loads.
gcc/tree-vect-patterns.cc