diff options
author | Alexandre Oliva <oliva@adacore.com> | 2024-12-12 11:43:09 -0300 |
---|---|---|
committer | Alexandre Oliva <oliva@gnu.org> | 2024-12-12 11:43:09 -0300 |
commit | 3eb6e1e3335fe0aabc79e75bf4d71366727c3971 (patch) | |
tree | d692b8da77092ccf1d0f925a1766f0acf418ac84 /gcc/value-range.cc | |
parent | e8febb641415fd80eabce1c4fdf2d4a4b411213b (diff) | |
download | gcc-3eb6e1e3335fe0aabc79e75bf4d71366727c3971.zip gcc-3eb6e1e3335fe0aabc79e75bf4d71366727c3971.tar.gz gcc-3eb6e1e3335fe0aabc79e75bf4d71366727c3971.tar.bz2 |
ifcombine field-merge: set upper bound for get_best_mode
A bootstrap on aarch64-linux-gnu revealed that sometimes (for example,
when building shorten_branches in final.cc) we will find such things
as MEM <unsigned int>, where unsigned int happens to be a variant of
the original unsigned int type, but with 64-bit alignment. This
unusual alignment circumstance caused (i) get_inner_reference to not
look inside the MEM, (ii) get_best_mode to choose DImode instead of
SImode to access the object, so we built a BIT_FIELD_REF that
attempted to select all 64 bits of a 32-bit object, and that failed
gimple verification ("position plus size exceeds size of referenced
object") because there aren't that many bits in the unsigned int
object.
This patch avoids this failure mode by limiting the bitfield range
with the size of the inner object, if it is a known constant.
This enables us to avoid creating a BIT_FIELD_REF and reusing the load
expr, but we still introduced a separate load, that would presumably
get optimized out, but that is easy enough to avoid in the first place
by reusing the SSA_NAME it was originally loaded into, so I
implemented that in make_bit_field_load.
for gcc/ChangeLog
* gimple-fold.cc (fold_truth_andor_for_ifcombine): Limit the
size of the bitregion in get_best_mode calls by the inner
object's type size, if known.
(make_bit_field_load): Reuse SSA_NAME if we're attempting to
issue an identical load.
Diffstat (limited to 'gcc/value-range.cc')
0 files changed, 0 insertions, 0 deletions