Re: [PATCH] range-op-float: Fix up float_widen_lhs_range [PR126641]

Jakub Jelinek <[email protected]> Thu, 6 Aug 2026 16:27:41 +0200
Newsgroups gmane.comp.gcc.patches
Message-ID <anSZ3cecw3UBTeRd@tucnak>
On Thu, Aug 06, 2026 at 04:11:12PM +0200, Aldy Hernandez wrote:
> I still think we should put in an assert in the real.cc code that dies
> hard if we try to blow past the significant size, like I had in the
> PR.  That way we can at least catch problems in this space without
> having to go through the hell of memory corruption.

I'm certainly not against that assert, perhaps it can be gcc_checking_assert
only though.

> Overall, I'm not a big fan of having to expose the internals of frange
> in this manner.  The fact that we have to do this, means we're either
> doing something wrong, or the API is missing something.  What could we
> provide to make this cleaner?

I admit it is ugly, but I think that is the sign the APIs protect developers
properly from using hacks like this.  In most cases, it is just fine if
one needs to go through the union_ way you've used, if we add APIs that
allow to change arbitrary bounds (e.g. set_lower_bound (i, value),
set_upper_bound (i, value), set_num_ranges or something like that, it will
make it easier to do such hacks everywhere.
I'd hope this is the only spot that needs to do such stuff, which is why
I went with the friend declaration.

> That being said, I think someone else should review this patch.  It's
> way beyond my circle of competence and I'd just be making stuff up :).
> If no one steps in, then I could take a stab at it.
> 
> Thanks for working on this.  I know it's been painful.
> 
> Aldy
> 
> p.s. Feel free to commit as is, to get everyone's builds back to
> sanity, and you can tackle any review as a follow-up.
> 
> > 
> > 2026-08-06  Jakub Jelinek  <[email protected]>
> > 
> > 	PR tree-optimization/126641
> > 	* value-range.h (class frange): Add float_widen_lhs_range
> > 	function as friend.
> > 	* range-op-float.cc (float_widen_lhs_range): No longer static.
> > 	Don't use set and union_ to merge adjusted pairs, instead
> > 	manipulate m_pairs directly.
> > 
> > 	* gcc.dg/pr126641.c: New test.

	Jakub