Re: [PATCH v2 bpf-next] bpf: improve the general precision of tnum_mul

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2025-08-18 at 20:23 +0200, Jakub Sitnicki wrote:
> On Fri, Aug 15, 2025 at 07:35 PM +0530, Nandakumar Edamana wrote:
> 
> [...]
> 
> > @@ -155,6 +163,14 @@ struct tnum tnum_intersect(struct tnum a, struct tnum b)
> >  	return TNUM(v & ~mu, mu);
> >  }
> >  
> > +struct tnum tnum_union(struct tnum a, struct tnum b)
> > +{
> > +	u64 v = a.value & b.value;
> > +	u64 mu = (a.value ^ b.value) | a.mask | b.mask;
> > +
> > +	return TNUM(v & ~mu, mu);
> > +}
> > +
> 
> Not sure I follow. So if I have two tnums that represent known contants,
> say a=(v=0b1010, m=0) and b=(v=0b0101, m=0), then their union is an
> unknown u=(v=0b0000, m=0b1111)?

Yes, because a and b have no bits in common.
As far as I understand, tnum_union() computes a tnum that is a
superset of both `a` and `b`. Maybe `union` is not the best name.





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux