https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128003
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <[email protected]>: https://gcc.gnu.org/g:a6d9810385f6773ff897fc5c4fe80bfbeef1a2fc commit r17-5403-ga6d9810385f6773ff897fc5c4fe80bfbeef1a2fc Author: Jakub Jelinek <[email protected]> Date: Tue Oct 20 12:11:19 2026 +0200 switchlower: Fix up middle/large/huge BITINT_TYPE handling [PR128003] If a BITINT_TYPE is wider than 64-bit (where we have a guarantee that each switch cluster has at most 64-bit span), jump_table_cluster::emit emits the value - low > high - low condition for clearly no match in this cluster (well, high - low is replaced by maximum of the narrower type). I've mistakenly used !TYPE_OVERFLOW_WRAPS condition whether it needs to be cast to unsigned before that subtraction/comparison. That should have been !TYPE_UNSIGNED, otherwise for -fwrapv values out of the range which are above the range are handled correctly (except the ones that wrap), but values below the range are mishandled, value - low > high - low isn't true for those but it is still out of range. Fixed thusly. 2026-10-20 Jakub Jelinek <[email protected]> PR tree-optimization/128003 * tree-switch-conversion.cc (jump_table_cluster::emit): Cast to unsigned_type_for whenever !TYPE_UNSIGNED rather than when !TYPE_OVERFLOW_WRAPS. * gcc.dg/torture/bitint-113.c: New test. Reviewed-by: Richard Biener <[email protected]>
