https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126153
--- Comment #24 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <[email protected]>: https://gcc.gnu.org/g:f3c62858532248b2ee73e20f8d13019a4cb3a210 commit r17-3857-gf3c62858532248b2ee73e20f8d13019a4cb3a210 Author: Richard Biener <[email protected]> Date: Wed Sep 2 09:46:31 2026 +0200 ipa: do not match bit-field predicate conditions against byte offsets Conditions of IPA predicates record the position of an aggregate load as a bit offset (ipa_load_from_parm_agg derives it from get_ref_base_and_extent_hwi and add_condition stores it verbatim), while the aggregate values of jump functions are indexed by byte offsets (ipa_argagg_value::unit_offset). evaluate_conditions_for_known_args bridged the two by simply dividing by BITS_PER_UNIT, which for a bit-field silently drops its sub-byte position and matches the constant recorded for the containing byte. The subsequent compatibility check only compares TYPE_SIZE, which is the mode size and therefore equal for a narrow bit-field type and a char, so the whole byte is then reinterpreted as the field with a VIEW_CONVERT_EXPR. In the testcase a 3-bit signed bit-field holding 1 sits at bits 2..4 of a byte whose value is 4; the byte is reinterpreted as -4, the guard ((int) p.f3.f7) >= 0 folds to false, the guarded call edge gets a false predicate and edge_set_predicate turns it into __builtin_unreachable. Everything dominated by the guard is then removed, main loses its return statement and falls through into _start. Since ipa_argagg_value_list cannot represent a sub-byte position, skip the lookup altogether when the condition is not byte aligned. Assisted-by: Claude Opus 5 PR ipa/126153 * ipa-fnsummary.cc (evaluate_conditions_for_known_args): Do not look up an aggregate value for a condition whose offset is not byte aligned. * gcc.dg/torture/pr126153.c: New test.
