https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127107

--- Comment #7 from Konstantinos Eleftheriou <konstantinos.eleftheriou at vrull 
dot eu> ---
(In reply to Drea Pinski from comment #4)
> This patch fixes the issue for me (I need to check other things still):
> ```
> diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
> index 207a7dcf944..6f8d0769fd1 100644
> --- a/gcc/tree-ssa-forwprop.cc
> +++ b/gcc/tree-ssa-forwprop.cc
> @@ -3652,6 +3652,7 @@ build_mul_high_seq (tree op1, tree op2, tree dest,
> location_t loc,
>  {
>    tree op_type = TREE_TYPE (op1);
>    unsigned int width = TYPE_PRECISION (op_type);
> +  gcc_assert (width * 2 <= MAX_FIXED_MODE_SIZE);
>    tree wide_type = build_nonstandard_integer_type (width * 2, 1);
> 
>    tree wide_a = gimple_convert (seq, loc, wide_type, op1);
> @@ -4534,16 +4535,15 @@ long_mul_classify_match (const vec<long_mul_summand>
> &summands,
>       consumes -- either via WIDEN_MULT_EXPR / MULT_HIGHPART conversion when
>       the target has a native 2N multiply, or via lower_long_mul_high_chain
>       when it does not.  LOW_PART rows emit a plain MULT_EXPR.  Emission
> -     needs a 2N mode to exist in the mode table AND the widening_mul pass
> -     to be active: without the pass, the emit could reach RTL expand as an
> -     unexpandable 2N multiply (e.g. OImode).  BITINT_TYPE is
> +     needs a 2N mode to exist and supported by the target.  BITINT_TYPE is
>       refused -- the long_mul_high_chain atom excludes it.  */
>    scalar_int_mode mode, wide_mode;
>    bool can_emit_high
>      = optimize_widening_mul_active_p ()
>        && TREE_CODE (lhs_type) != BITINT_TYPE
>        && is_a <scalar_int_mode> (TYPE_MODE (lhs_type), &mode)
> -      && GET_MODE_2XWIDER_MODE (mode).exists (&wide_mode);
> +      && GET_MODE_2XWIDER_MODE (mode).exists (&wide_mode)
> +      && targetm.scalar_mode_supported_p (wide_mode);
> 
>    for (const long_mul_row &row : long_mul_table)
>      {
> 
> ```

Thanks Andrew!

I think that the assertion will trip on AVR. Maybe use `GET_MODE_BITSIZE
(wide_mode) <= MAX_FIXED_MODE_SIZE` instead?

Reply via email to