This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Improve PR30911 and PR31023, Ada and VRP


> > I see.  I couldn't find any such pragma in the docs, is this a new feature?
> 
> It's something that could be done for this case.

I'm a bit confused - I thought you were saying that __builtin_assume is not
feasible since in some programs the front-end knows that all variables are
initialized (because of some pragma) but that too many __builtin_assume calls
would need to be generated to inform the optimizers.  I don't understand now
whether the compiler does sometimes know this, or whether you are saying that
it might be a useful future enhancement.

> > I thought the issue was whether integer types with restricted ranges
> > should be eliminated from the middle-end in favour of __builtin_assume.
> > As for the pragma that requires initialization, presumably in this case
> > most range checks wouldn't be needed, so the front-end could simply not
> > generate them in the first place.
> 
> I don't follow.  If I have a subtype and an assignment to it, whether or
> not the variables are initialized is completely orthogonal to the issue of
> whether range checks are required.

I was thinking of the following case: a type of a variable X has range 1 .. 10,
and X is being used to access an array A with index range 1 .. 10, thusly: A(X).
Currently a check is (or should be) emitted to check that 1 <= X <= 10.  This
is because X might be outside the range of its type.  However if X got an initial
value then you know it must be inside the range of its type, so the check can be
omitted.  This is wrong of course since the value of X might be the result of an
unchecked conversion.

Ciao,

Duncan.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]