https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113491
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:291e00e2d88a352f46cd539e3c5785982dc3fdd9 commit r14-8302-g291e00e2d88a352f46cd539e3c5785982dc3fdd9 Author: Jakub Jelinek <ja...@redhat.com> Date: Sat Jan 20 12:35:38 2024 +0100 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 <ja...@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.