Re: [PATCH] amdgcn, libm: fix infinite loop
Jeff Johnston <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <CAOox84vuGx2cwLStvYnX+KPizNwphDQnCk+SeaieORQuDCsbfQ@mail.gmail.com> |
Patch applied. Thanks. -- Jeff J. On Fri, Aug 8, 2025 at 4:15 AM Thomas Schwinge <[email protected]> wrote: > Hi Andrew! > > On 2025-08-07T13:09:41+0000, Andrew Stubbs <[email protected]> wrote: > > The end condition on this loop, unlike all the other similar loops, is > > "i >= 0", which is a problem because "i <<= 1" can go negative and then > zero if > > you continue shifting, and so back to true, again. This isn't a problem > for > > the loop in the scalar implementation, but it means we need to mask the > shift > > in the vector implementation. > > > > This fixes GCC PR#121392. > > Thanks, I confirm this fixes the issue. > > I suggest you 'git push', or I can do it for you if you don't have access > to newlib Git -- or, I'll be happy to sponsor you to get access, as > maintainer of the GCN parts in newlib. > (<https://sourceware.org/cgi-bin/pdw/ps_form.cgi> has the instructions > for the latter.) > > > Grüße > Thomas > > > > newlib/libm/machine/amdgcn/v64sf_fmod.c | 7 +++++-- > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > diff --git a/newlib/libm/machine/amdgcn/v64sf_fmod.c > b/newlib/libm/machine/amdgcn/v64sf_fmod.c > > index 7302420ad..b62b81929 100644 > > --- a/newlib/libm/machine/amdgcn/v64sf_fmod.c > > +++ b/newlib/libm/machine/amdgcn/v64sf_fmod.c > > @@ -70,8 +70,11 @@ DEF_VS_MATH_FUNC (v64sf, fmodf, v64sf x, v64sf y) > > v64si iy; > > VECTOR_IF (hy < 0x00800000, cond) // subnormal y > > iy = VECTOR_INIT (-126); > > - for (v64si i = (hy << 8); !ALL_ZEROES_P (cond & (i >= 0)); i <<= 1) > > - VECTOR_COND_MOVE (iy, iy - 1, cond & (i >= 0)); > > + for (v64si i = (hy << 8); !ALL_ZEROES_P (cond & (i >= 0)); /* i <<= > 1 */) > > + { > > + VECTOR_COND_MOVE (iy, iy - 1, cond & (i >= 0)); > > + VECTOR_COND_MOVE (i, i << 1, cond & (i >= 0)); > > + } > > VECTOR_ELSE (cond) > > VECTOR_COND_MOVE (iy, (hy >> 23) - 127, cond); > > VECTOR_ENDIF > > -- > > 2.50.0 > >