https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126153
--- Comment #27 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:73680e030d24d966121f608d7611848d75ae8045 commit r17-4020-g73680e030d24d966121f608d7611848d75ae8045 Author: Richard Biener <[email protected]> Date: Wed Sep 2 10:04:04 2026 +0200 ipa: require matching precision before VIEW_CONVERT_EXPR of a known value evaluate_conditions_for_known_args reinterprets the aggregate constant found for a condition into the type of the condition whenever the two types have the same TYPE_SIZE. TYPE_SIZE only says how much storage a type occupies, not how many of those bits carry the value, so a bit-field type and the byte containing it compare equal: TYPE_SIZE of <unnamed-signed:3> and of char are both 8. The resulting VIEW_CONVERT_EXPR is folded through native_encode_expr and native_interpret_expr, which keeps the least significant TYPE_PRECISION bits of the byte. Those are the bit-field only under little-endian bit numbering. With big-endian bit numbering, either because of the target or because of a reversed scalar storage order, the field lives in the most significant bits instead and the reinterpretation silently yields an unrelated value. In the testcase the byte 0x24 holds the value 1 in a reverse storage order 3-bit signed bit-field, but is misread as -4, which turns the guard ((int) p.f3.f7) >= 0 into a false predicate, and edge_set_predicate then replaces the guarded call with __builtin_unreachable. Require the precisions to be matching the modes. Assisted-by: Claude Opus 5 <[email protected]> PR ipa/126153 * ipa-fnsummary.cc (evaluate_conditions_for_known_args): Only reinterpret a known aggregate value into the type of the condition if both types have the same precision. * gcc.dg/torture/ipa-bitfield-predicate-1.c: New test.
