On Mon, Feb 17, 2014 at 11:27 AM, Eric Botcazou <ebotca...@adacore.com> wrote: >> There is nothing obvious I think, i.e. that's debatable. I agree that a VCE >> from a 32-bit object to a 32-bit integer with 24-bit precision should not >> clear the upper 8 bits (so the REDUCE_BIT_FIELD part of my patch is wrong). >> But here we have a VCE from a 24-bit object to a 32-bit integer with 24-bit >> precision which reads *more bits* than the size of the source type; that I >> think is plain wrong and is fixed by the bit-field extraction in the patch. > > Revised patch along these lines attached. Although I agree that it's a bit of > a kludge, it's quite localized and plausible IMO.
Woudln't it be better to do this in the series of "conversions", that is inside the preceeding if-statement? (the integral type case using convert_modes looks weird enough, so adding this kind-of "less" weird one there looks sensible) Ok with moving it there (before the else if (!MEM_P (op0))). You probably want to guard with INTEGRAL_TYPE_P (type) as well, not only GET_MODE (op0) != mode - just to prepare for weird stuff like a vector-type where TYPE_PRECISION means sth else. Thanks, Richard. > > * expr.c (expand_expr_real_1) <case VIEW_CONVERT_EXPR>: For a > bit-field > destination type, extract exactly the number of valid bits if the > source > type isn't integral or has a different precision. > > > -- > Eric Botcazou