> From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches-
> ow...@gcc.gnu.org] On Behalf Of Thomas Preud'homme
> 
> > From: Richard Biener [mailto:richard.guent...@gmail.com]
> >
> > +                 /* Convert the result of load if necessary.  */
> > +                 if (!useless_type_conversion_p (TREE_TYPE (tgt),
> > +                                                 TREE_TYPE (val_tmp)))
> > +                   {
> >
> > why's that?  Shouldn't the load already be emitted of the correct type?
> 
> The size would be correct and I wasn't sure if the sign matters. I've read
> useless_type_conversion_p since and it seems I was overly worried.

Sorry I made some mistakes in my reply. Signedness does matter and even
if the sign would be fine, the load size could be different from the target
size. It's the same kind of difference as size Vs range in the
symbolic_number structure.

Consider the following case:

int
foo (char *a)
{
  return a[0] | (a[1] << 8);
}

The load size in this case would be 16 bits while the target size would be
32 bits. Therefore a conversion would be needed.

Best regards,

Thomas 



Reply via email to