This is the mail archive of the gcc@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: PR 23046. Folding predicates involving TYPE_MAX_VALUE/TYPE_MIN_VALUE (Ada RFC)


* Robert Dewar:

> Florian Weimer wrote:
>> If this still doesn't convince you, here's an example which doesn't
>> use Ada.Unchecked_Conversion at all.
>
> this example must print Success, that is guaranteed by the RM

Yes, I think so.

What about the first one in PR21573?  IMHO, the GNAT Reference Manual
makes a guarantee that it prints SUCESS, too, but I could be
misreading the documentation.

> it is definitely critical that 'Valid not make "in-range"
> assumptions.

> the actual problem is optimization of this
> routine presumably:

>       function bug3_p__tRP (A : bug3_p__t; F : boolean) return integer is

Indeed.  In this case, bug3_p__t has TYPE_MIN_VALUE and TYPE_MAX_VALUE
set according to T'First'Enum_Rep and T'Last'Enum_Rep.  Even without
VRP, add_case_node and node_has_high_bound in stmt.c check these
attributes and use them in optimizations.

> the unchecked conversion to unsigned must prevent any optimization.
> the optimizer must not be able to "see through" an unchecked conversion!

I don't think we currently have a convenient way to express such an
optimization barrier in the tree language.

I fear that such barriers are also needed for all checks on scalars,
by the way, not just 'Valid.


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