diff options
author | Jakub Jelinek <jakub@redhat.com> | 2024-01-20 12:35:38 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2024-01-20 12:35:38 +0100 |
commit | 291e00e2d88a352f46cd539e3c5785982dc3fdd9 (patch) | |
tree | 6f3b5bc827d8c21a2963ff751789dcdd22776ed7 /gcc/fortran/parse.cc | |
parent | 615e25c82de97acc17ab438f88d6788cf7ffe1d6 (diff) | |
download | gcc-291e00e2d88a352f46cd539e3c5785982dc3fdd9.zip gcc-291e00e2d88a352f46cd539e3c5785982dc3fdd9.tar.gz gcc-291e00e2d88a352f46cd539e3c5785982dc3fdd9.tar.bz2 |
tree-switch-conversion: Bugfixes for _BitInt [PR113491]
The following patch fixes various issues with large/huge _BitInt used as switch
expressions.
In particular:
1) the indexes in CONSTRUCTORs shouldn't be types with precision larger than
sizetype precision, varasm uses wi::to_offset on those and too large
indexes ICE; we've already checked earlier that the cluster is at most
sizetype bits and arrays can't be larger than that anyway
2) some spots were using SCALAR_INT_TYPE_MODE or
lang_hooks.types.type_for_mode on TYPE_MODE to determine types to use,
that obviously doesn't work for the large/huge BITINT_TYPE
3) like the recent change in the C FE, this patch makes sure we don't create
ARRAY_REFs with indexes with precision above sizetype precision, because
bitint lowering isn't prepared for that and because the indexes can't be
larger than sizetype anyway; the subtraction of the cluster minimum from
the index obviously needs to be done in unsigned __int128 or large/huge
BITINT_TYPE, but then we cast to sizetype if the precision is larger than
sizetype
2024-01-20 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/113491
* tree-switch-conversion.cc (switch_conversion::build_constructors):
If elt.index has precision higher than sizetype, fold_convert it to
sizetype.
(switch_conversion::array_value_type): Return type if type is
BITINT_TYPE with precision above MAX_FIXED_MODE_SIZE or with BLKmode.
(switch_conversion::build_arrays): Use unsigned_type_for rather than
lang_hooks.types.type_for_mode if utype is BITINT_TYPE with precision
above MAX_FIXED_MODE_SIZE or with BLKmode. If utype has precision
higher than sizetype, use sizetype as tidx type and fold_convert the
subtraction to sizetype.
* gcc.dg/torture/bitint-51.c: New test.
Diffstat (limited to 'gcc/fortran/parse.cc')
0 files changed, 0 insertions, 0 deletions