https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128699
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- So, on the last testcase: b_5 = (_BitInt(255)) t_4(D); c_6 = -b_5; _1 = (unsigned _BitInt(129)) c_6; _2 = (_BitInt(192)) _1; _3 = _2 >> 1; we merge everything. Merging everything up to _2 is fine, those are all casts or mergeable ops. Or merging _1 and _2 with _3 is also fine separately, even when RSHIFT_EXPR is never mergeable op, it uses handle_operand and can deal with casts in there, or loads. But it is not ok to merge all this together, as this testcase shows, e.g. cases which use prepare_data_in_out must be done only from outermost lower_mergeable_stmt (or lower_addsub_overflow or lower_bit_query). Now, some calls to prepare_data_in_out are guarded on m_upwards_2limb and do something else otherwise, e.g. handle_operand for some constants, handle_casts for some casts. But handle_plus_minus or handle_lshift (the latter for the mergeable LSHIFT_EXPR, i.e. by very small constant) or handle_load for the bit-field load case. The reason why they are problematic is that they need to track some state between iterations of the loop (carry for handle_plus_minus, some bits from the previously handled limb for mergeable LSHIFT_EXPR). Now, calls which don't do m_upwards_2limb break this, e.g. in lower_shift_stmt it can call handle_operand multiple times with non-constant idx (normally it is ok to have it called twice, once with m_first, once with !m_first, for the first and second handled limb, everything else should be with constant idx). When this is violated, we get multiple definitions of some SSA_NAMEs (e.g. the handle_plus_minus data_out) in the IL and that is why we ICE. So, we need to avoid merging everything and goto force_name in that case for at least one SSA_NAME, the question is which one. What complicates this is that we iterate over the SSA_NAMEs in SSA_NAME_VERSION order and decide based on various conditions which include stmts used in rhs1 and single use stmt (if any), but the other SSA_NAMEs in the chain could have been already processed or might be processed later on.
