On Wed, Jul 30, 2025 at 12:37:33PM GMT, Jakub Jelinek wrote: > On Wed, Jul 30, 2025 at 06:24:42PM +0800, Yang Yujie wrote: > > On Wed, Jul 30, 2025 at 12:19:24PM GMT, Jakub Jelinek wrote: > > > On Wed, Jul 30, 2025 at 06:15:56PM +0800, Yang Yujie wrote: > > > > So wouldn't it be simpler if I just change the comparison in my patch > > > > into > > > > a memcmp? This works regardless of how comparison is implemented. > > > > (We all assume that expression (x) may have its address taken.) > > > > > > No. memcmp after memcpy will be always identical. > > > By treating the memcpy copied data as the promoted _BitInt (without > > > knowing > > > anything about it) and shifting right by S (x) for unsigned it needs to do > > > the shift and the result will be 0 if correct and non-zero on error, > > > similarly for signed shifting right by S (x) - 1 the result will be 0 or > > > -1 > > > if correct and otherwise erroneous. > > > > > > Jakub > > > > I mean do the casting first: > > > > typeof(x) __y = (typeof(x)) __x; > > > > and then compare the objects of __y and (x) with memcmp. > > You don't want to do memcmp when it includes uninitialized bits (which is > the case on loongarch). I really prefer the shift. > > Jakub
I'm OK with your implementation. Just curious, do you mean that memcmp shouldn't be used on "(x)" at all?