https://gcc.gnu.org/g:a793e66d706e04e0600b852cd8818bde21ae3599
commit r17-5325-ga793e66d706e04e0600b852cd8818bde21ae3599 Author: Richard Biener <[email protected]> Date: Mon Oct 19 10:44:28 2026 +0200 tree-optimization/127958 - avoid building invalid BIT_FIELD_REF FRE builds a temporary BIT_FIELD_REF for redundant store elimination but fails to constrain the resulting offset so we eventually ICE when using bit_field_offset later which assumes the offset fits in a poly_uint64. PR tree-optimization/127958 * tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_stmt): Check whether the offset for a BIT_FIELD_REF fits before using it as a lookup ref for redundant store elimination. Diff: --- gcc/tree-ssa-sccvn.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index 63d7110d35cf..ac9cb6e7e4c1 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -7510,16 +7510,17 @@ eliminate_dom_walker::eliminate_stmt (basic_block b, gimple_stmt_iterator *gsi) TYPE_UNSIGNED (TREE_TYPE (lhs))); if (TREE_CODE (lhs) == COMPONENT_REF) { - tree foff = component_ref_field_offset (lhs); + tree bpos, foff = component_ref_field_offset (lhs); tree f = TREE_OPERAND (lhs, 1); - if (!poly_int_tree_p (foff)) + if (!poly_int_tree_p (foff) + || !tree_fits_poly_uint64_p + (bpos = bit_from_pos (foff, + DECL_FIELD_BIT_OFFSET (f)))) lookup_lhs = NULL_TREE; else lookup_lhs = build3 (BIT_FIELD_REF, ltype, TREE_OPERAND (lhs, 0), - TYPE_SIZE (TREE_TYPE (lhs)), - bit_from_pos - (foff, DECL_FIELD_BIT_OFFSET (f))); + TYPE_SIZE (TREE_TYPE (lhs)), bpos); } else lookup_lhs = build2 (MEM_REF, ltype,
