On Wed, 12 Oct 2022, Andrew MacLeod wrote:
>
> On 10/12/22 10:39, Jakub Jelinek wrote:
> > On Wed, Oct 12, 2022 at 10:31:00AM -0400, Andrew MacLeod wrote:
> >> I presume you are looking to get this working for this release, making the
> >> priority high? :-)
> > Yes. So that we can claim we actually support C++23 Portable Assumptions
> > and OpenMP assume directive's hold clauses for something non-trivial so
> > people won't be afraid to actually use it.
> > Of course, first the posted patch needs to be reviewed and only once it gets
> > in, the ranger/GORI part can follow. As the latter is only an optimization,
> > it can be done incrementally.
>
> I will start poking at something to find ranges for parameters from the return
> backwards.
If the return were
if (return_val)
return return_val;
you could use path-ranger with the parameter SSA default defs as
"interesting". So you "only" need to somehow interpret the return
statement as such and do path rangers compute_ranges ()
>
> >> Intersection I believe...? I think the value from the assume's should add
> >> restrictions to the range..
> > Sure, sorry.
> >
> >> I figured as much, I was just wondering if there might be some way to
> >> "simplify" certain things by processing it and turning each parameter query
> >> into a smaller function returning the range we determined from the main
> >> one... but perhaps that is more complicated.
> > We don't really know what the condition is, it can be pretty arbitrary
> > expression (well, e.g. for C++ conditional expression, so say
> > [[assume (var = foo ())]];
> > is not valid but
> > [[assume ((var = foo ()))]];
> > is. And with GNU statement expressions it can do a lot of stuff and until
> > we e.g. inline into it and optimize it a little, we don't really know what
> > it will be like.
> >
> >
>
> No, I just meant that once we finally process the complicated function, and
> decide the final range we are storing is for x_1 is say [20,30], we could
> replace the assume call site with something like
>
> int assume03_x (x) { if (x>= 20 || x <= 30) return x; gcc_unreachable(); }
>
> then at call sites:
>
> x_5 = assume03_x(x_3);
>
> For that matter, once all the assume functions have been processed, we could
> textually replace the assume call with an expression which represents the
> determined range... Kind of our own mini inlining? Maybe thats even better
> than adding any kind of support in fold_using_range.. just let things
> naturally fall into place?
>
> .ASSUME_blah ( , , x_4);
>
> where if x is determined to be [20, 30][50,60] could be textually "expanded"
> in the IL with
>
> if (x<20 || x>60 || (x>30 && x < 50)) gcc_unreachcable();
>
> for each of the parameters? If we processed this like early inlining, we
> could maybe expose the entire thing to optimization that way?
>
> Andrew
>
>
>
--
Richard Biener <[email protected]>
SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
HRB 36809 (AG Nuernberg)