On Sun, 2 Jun 2024, Kewen Lin wrote:

> diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc
> index 571923c08ef..d52cbdf0b99 100644
> --- a/gcc/m2/gm2-gcc/m2type.cc
> +++ b/gcc/m2/gm2-gcc/m2type.cc
> @@ -1420,7 +1420,7 @@ build_m2_short_real_node (void)
>    /* Define `REAL'.  */
>  
>    c = make_node (REAL_TYPE);
> -  TYPE_PRECISION (c) = FLOAT_TYPE_SIZE;
> +  TYPE_PRECISION (c) = TYPE_PRECISION (float_type_node);
>    layout_type (c);
>    return c;
>  }
> @@ -1433,7 +1433,7 @@ build_m2_real_node (void)
>    /* Define `REAL'.  */
>  
>    c = make_node (REAL_TYPE);
> -  TYPE_PRECISION (c) = DOUBLE_TYPE_SIZE;
> +  TYPE_PRECISION (c) = TYPE_PRECISION (double_type_node);
>    layout_type (c);
>    return c;
>  }
> @@ -1447,7 +1447,7 @@ build_m2_long_real_node (void)
>    if (M2Options_GetIBMLongDouble ())
>      {
>        longreal = make_node (REAL_TYPE);
> -      TYPE_PRECISION (longreal) = LONG_DOUBLE_TYPE_SIZE;
> +      TYPE_PRECISION (longreal) = TYPE_PRECISION (long_double_type_node);

This looks rather like m2 would still have the same problem the generic 
code previously had: going via precision when that might not uniquely 
determine the desired machine mode.  And so making sure to use the right 
machine mode as done when setting up long_double_type_node etc. would be 
better than keeping this code copying TYPE_PRECISION and hoping to 
determine a machine mode from that.  It certainly looks like this code 
wants to match float, double and long double, rather than possibly getting 
a different mode with possibly the same TYPE_PRECISION.

(I don't know if the M2Options_GetIBMLongDouble call would be needed at 
all once you use the machine mode for long double in a reliable way, or 
whether this code could be further simplified.)

-- 
Joseph S. Myers
josmy...@redhat.com

Reply via email to