Re: [PATCH 0/4] Replace nonzero_p with contains_zero_p

Aldy Hernandez <[email protected]> Thu, 6 Aug 2026 12:46:01 +0200
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>
On Thu, Aug 06, 2026 at 10:28:29AM +0200, Richard Biener wrote:
> On Wed, 5 Aug 2026, Aldy Hernandez wrote:
> 
> > On Wed, Aug 05, 2026 at 04:17:19PM +0200, Aldy Hernandez wrote:
> > > Per our discussion, nonzero_p() has always been a bit insane.  It only
> > > returns true for ~[0,0] so even [13,13] is considered false.
> > > Introduce contains_zero_p(), which from the looks of it, we've already
> > > been hand crafting, as direct nonzero_p() calls were few.
> > > 
> > > How does this look?
> > 
> > BTW, I ran my usual LAPACK source files through each patch
> > independently, and there are no changes to assembly, so in theory this
> > whole set is surprisingly a non-functional change.
> 
> You also add contains_zero_p for frange, but what does this actually
> mean there?  irange already had contains_zero_p.

I meant to remove the free-standing contains_zero_p(&irange) as a
follow-up, replacing all uses of it with r.contains_zero_p().

> I suppose we can document contains_zero_p to mean that
> for a value with the range val == T(0) may evaluate true?  So for
> frange this means either -0.0 or 0.0?  irange implements
> it in terms of contains_p which is already there for frange
> and that implements it as >= && <=.

Good call.  I'm adding:

+  // True if val == 0 may hold for some value in the range; for a float
+  // range that means +0.0 or -0.0.
+  virtual bool contains_zero_p () const = 0;

Thanks.
Aldy