On Wed, Dec 09, 2020 at 09:03:36AM +0100, Richard Biener wrote:
> > For Ada with LTO, boolean_{false,true}_node can be 1-bit precision boolean,
> > while TREE_TYPE (lhs) can be 8-bit precision boolean and thus we can end up
> > with wide_int mismatches.
> > 
> > The following patch fixes it by using TYPE_{MIN,MAX}_VALUE instead.
> 
> Are you sure the Ada boolean types have 1/0 as MIN/MAX value?  ISTR
> that's not the case as the middle-end has to support out-of-bound
> values.  Now, this might mean using MIN/MAX value is even required
> since the transform cannot assume 0/[-]1 here?
> 
> So maybe do
> 
> >    if (TREE_CODE (TREE_TYPE (lhs)) == BOOLEAN_TYPE
>          && TYPE_PRECISION (TREE_TYPE (lhs)) == 1)
> 
> and thus rely on get_range_info for Ada?

I'm sure:
  /* In Ada, we use an unsigned 8-bit type for the default boolean type.  */
  boolean_type_node = make_unsigned_type (8);
  TREE_SET_CODE (boolean_type_node, BOOLEAN_TYPE);
  SET_TYPE_RM_MAX_VALUE (boolean_type_node,
                         build_int_cst (boolean_type_node, 1));
                                                           ^^^ Here
  SET_TYPE_RM_SIZE (boolean_type_node, bitsize_int (1));
  boolean_true_node = TYPE_MAX_VALUE (boolean_type_node);
  boolean_false_node = TYPE_MIN_VALUE (boolean_type_node);

The build_nonstandard_boolean_type that is not the case and
TYPE_MAX_VALUE is -1 rather than 0, but I've checked all uses
of that function and it always just creates an element type
for VECTOR_TYPEs, so I think it shouldn't affect code that
looks at BOOLEAN_TYPE non-VECTOR_TYPEs.

        Jakub

Reply via email to