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: Handling non-constant bounds in extract_range_from_cond


As a programmer when I use 'Valid I expect the compiler to do
its best to return the "real" result at the expense
of performance, even if the standard probably doesn't
guarantee it. It's more a quality of implementation issue.

Why not replace 'Valid by a function call, with the
body unknown to the optimizer (unoptimizable/inlinable/whatever)?

R := X'Valid
=>
R := Check_Valid(X,bound information)
-- and make sure the compiler cannot know anything about Check_Valid
-- at the point of the call and is forced to generate a call

May be there's no way to say that about a function to the backend.

Another possibility to add some backend representation
of "don't assume anything about this value":

R := (no_information(X))'Valid

On Mon, 2004-11-29 at 22:53, Richard Kenner wrote:
> [...] These sorts of optimizations (knowing that comparisons against known
> ranges are true) tend to be useful in code that has lots of macros so you
> can eliminate choices in many macro invocations.  But this is not a type
> of coding used in Ada, which is where the subtypes are present.  So I think,
> on balance, that the "Principle of Least Surprise" trumps the possible
> optimization benefit here.

Agreed.

Laurent


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