On Tue, Jul 15, 2025 at 08:36:46AM -0700, Andrew Pinski wrote:
> On Tue, Jul 15, 2025 at 6:06 AM Jakub Jelinek <ja...@redhat.com> wrote:
> >
> > On Tue, Jul 15, 2025 at 08:21:50AM -0400, Jason Merrill wrote:
> > > Given the above that seems rather unlikely, but I suppose it's fine if you
> > > want to do it that way.  The patch is OK either way.
> >
> > Committed just the v2 patch.  I can test your patch next with other patches,
> > or do you want to test/commit it yourself?
> 
> Just an FYI, this broke aarch64 build since libgcc has -Werror on
> there and we get warnings now in libbid code:
> ```
> ../../../gcc/libgcc/config/libbid/bid_binarydecimal.c: In function
> ‘__binary32_to_bid128’:
> ../../../gcc/libgcc/config/libbid/bid_binarydecimal.c:130:31: error:
> variable ‘c3’ set but not used [-Werror=unused-but-set-variable=]
>   130 | { unsigned long long c0,c1,c2,c3;                               \
>       |                               ^~
> ../../../gcc/libgcc/config/libbid/bid_binarydecimal.c:146842:5: note:
> in expansion of macro ‘__mul_10x256_to_256’
> 146842 |     __mul_10x256_to_256 (z.w[5], z.w[4], z.w[3], z.w[2],
> z.w[5], z.w[4],
>        |     ^~~~~~~~~~~~~~~~~~~
> ```
> https://builder.sourceware.org/buildbot/#/builders/311/builds/1483
> 
> I will see if there is anything simple to be done in the next few hours.

#define __mul_10x64(sum,carryout,input,carryin)                         \
{ unsigned long long s3 = (input) + ((input) >> 2);                     \
  (carryout) = ((s3 < (unsigned long long)(input))<<3) + (s3>>61);      \
  s3 = (s3<<3) + ((input&3)<<1);                                        \
  (sum) = s3 + (carryin);                                               \
  if ((unsigned long long)(sum) < s3) ++(carryout);                     \
}

// Multiply a 256-bit number by 10, assuming no overflow

#define __mul_10x256_to_256(p3,p2,p1,p0,a3,a2,a1,a0)            \
{ unsigned long long c0,c1,c2,c3;                               \
  __mul_10x64(p0,c0,a0,0ull);                                   \
  __mul_10x64(p1,c1,a1,c0);                                     \
  __mul_10x64(p2,c2,a2,c1);                                     \
  __mul_10x64(p3,c3,a3,c2);                                     \
}

So yeah, it is clear why -Wunused-but-set-variable=1 doesn't
warn about it, there is a useless assignment to c3 and then conditional
++c3.  And it is clear why it does warn now.

Not having c3 would mean having special macro for the final step,
so I think it is better to just

2025-07-15  Jakub Jelinek  <ja...@redhat.com>

        * bid_binarydecimal.c (__mul_10x256_to_256): Quiet
        -Wunused-but-set-variable=3 warning.

--- libgcc/config/libbid/bid_binarydecimal.c.jj 2025-04-08 14:09:53.599413906 
+0200
+++ libgcc/config/libbid/bid_binarydecimal.c    2025-07-15 18:02:15.494219552 
+0200
@@ -132,6 +132,7 @@ UINT64 CY;
   __mul_10x64(p1,c1,a1,c0);                                     \
   __mul_10x64(p2,c2,a2,c1);                                     \
   __mul_10x64(p3,c3,a3,c2);                                     \
+  (void)c3;                                                    \
 }
 
 // Set up indices for low and high parts, depending on the endian-ness.


Untested...

        Jakub

Reply via email to