This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] for PRs 27639 and 26719
Hello,
> > > does not truncate tmp2, so at most VRP can handle this with appropriate
> > > range information.
> >
> > Hi Richard, I'm not sure what you mean by "truncate". If supertype
> > is the Ada base type of subtype, then casting to subtype doesn't do
> > anything, except tell the compiler (VRP) that either tmp2 is in the
> > range of subtype or the program is erroneous. It certainly doesn't
> > change the numerical value in any way. So there are two cases:
> > (a) tmp2 is in the range of subtype, in which case
> > (supertype)(subtype)tmp2 gives tmp2, or
> > (b) tmp2 is not in the range of the subtype [*], in which case the
> > program is erroneous, so you can assume that (supertype)(subtype)tmp2
> > yields tmp2 if you want.
> > So there is no need to prove anything here, certainly there are no
> > issues with truncation.
>
> Ok, this undefinedness would need to be teached to fold. Certainly
> we "preserve" truncation for types with different TYPE_PRECISION or
> mode (of course).
the point is that subtype and supertype always have the same
TYPE_PRECISION (and the same mode).
Zdenek
> See the fold_unary case for NOP_EXPR at
>
> /* Handle cases of two conversions in a row. */
> if (TREE_CODE (op0) == NOP_EXPR
> || TREE_CODE (op0) == CONVERT_EXPR)
> ...
>
> Richard.
>
> >
> > Duncan.
> >
> > [*] in which case it is presumably an uninitialized variable or
> > equivalent, since otherwise we would not be executing this code
> > due to the range checks inserted by the front-end.
> >
> >
>
> --
> Richard Guenther <rguenther@suse.de>
> Novell / SUSE Labs