On Mon, Aug 10, 2026 at 11:41 PM Patrick Palka <[email protected]> wrote:
>
> On Mon, 10 Aug 2026, Kael Andrew Alonzo Franco wrote:
>
> > len is known to be 1 so return 1.
> > Helps with speeding up C++ optimizers.
>
> This is effectively manually performing a micro-optimization that
> all supported compilers are perfectly capable of, constant propagation.
> Do we want to be pushing such patches at the expense of cluttering
> the output of git blame?

It's actually a mis-optimization since you'd have to load 1 into the
return register when it is already in the register holding len.  So it
requires optimizing back.

Richard.

>
> >
> > Obvious fix so pushed.
> >
> > gcc/ChangeLog:
> >
> >       * wide-int.cc (canonize): Use return 1 instead of return len.
> >
> > Signed-off-by: Kael Andrew Franco <[email protected]>
> > ---
> >  gcc/wide-int.cc | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/gcc/wide-int.cc b/gcc/wide-int.cc
> > index c2c424344a2..668b2e4ea7d 100644
> > --- a/gcc/wide-int.cc
> > +++ b/gcc/wide-int.cc
> > @@ -90,7 +90,7 @@ canonize (HOST_WIDE_INT *val, unsigned int len, unsigned 
> > int precision)
> >      len = blocks_needed;
> >
> >    if (len == 1)
> > -    return len;
> > +    return 1;
> >
> >    top = val[len - 1];
> >    if (len * HOST_BITS_PER_WIDE_INT > precision)
> > --
> > 2.55.0
> >
> >
>

Reply via email to