This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Handling non-constant bounds in extract_range_from_cond
- From: Laurent GUERBY <laurent at guerby dot net>
- To: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>
- Cc: law at redhat dot com, gcc-patches at gcc dot gnu dot org
- Date: Mon, 29 Nov 2004 23:08:49 +0100
- Subject: Re: Handling non-constant bounds in extract_range_from_cond
- References: <10411292153.AA01730@vlsi1.ultra.nyu.edu>
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