Sorry that I don't understand tree type system well, so here are two more questions, could you please explain little bit more? Thanks very much.
On Tue, Oct 1, 2013 at 6:50 PM, Richard Biener <richard.guent...@gmail.com> wrote: > On Mon, Sep 30, 2013 at 7:39 AM, bin.cheng <bin.ch...@arm.com> wrote: > > I don't think you need > > + /* Sign extend off if expr is in type which has lower precision > + than HOST_WIDE_INT. */ > + if (TYPE_PRECISION (TREE_TYPE (expr)) <= HOST_BITS_PER_WIDE_INT) > + off = sext_hwi (off, TYPE_PRECISION (TREE_TYPE (expr))); Is it possible to have type of expr smaller than the type of embedded offset (i.e., sizetype)? Should the sign extend be against sizetype or it's safe with TREE_TYPE(expr)? > > at least it would be suspicious if you did ... > > The only case that I can think of points to a bug in strip_offset_1 > again, namely if sizetype (the type of all offsets) is smaller than > a HOST_WIDE_INT in which case > > + boffset = int_cst_value (DECL_FIELD_BIT_OFFSET (field)); > + *offset = off0 + int_cst_value (tmp) + boffset / BITS_PER_UNIT; > > is wrong as boffset / BITS_PER_UNIT does not do a signed division > then (for negative boffset which AFAIK does not happen - but it would > be technically allowed). Thus, the predicates like > > + && cst_and_fits_in_hwi (tmp) > > would need to be amended with a check that the MSB is not set. I am confused, why "boffset / BITS_PER_UNIT" won't do signed division and how it relates to "sizetype smaller than HOST_WIDE_INT"? If sizetype is smaller, won't int_cst_value sign extends it into HOST_WIDE_INT? Thanks. bin -- Best Regards.