[Bug target/97004] [nvptx] __int128 initializer incorrect
vries at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Sep 10 19:33:15 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97004
Tom de Vries <vries at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
Target Milestone|--- |11.0
--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #2)
> (In reply to Tom de Vries from comment #1)
> > Tentative patch:
> > ...
> > diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
> > index 0376ad6ce9f..26868590322 100644
> > --- a/gcc/config/nvptx/nvptx.c
> > +++ b/gcc/config/nvptx/nvptx.c
> > @@ -2054,7 +2054,11 @@ nvptx_assemble_value (unsigned HOST_WIDE_INT val,
> > unsigned size)
> >
> > for (unsigned part = 0; size; size -= part)
> > {
> > - val >>= part * BITS_PER_UNIT;
> > + if (part == sizeof (val))
>
> That assumes that CHAR_BIT == BITS_PER_UNIT, which is mostly the case, but
> shouldn't be relied on.
> Perhaps just use
> val >>= (part * BITS_PER_UNIT / 2);
> val >>= (part * BITS_PER_UNIT / 2);
> or if (part * BITS_PER_UNIT == sizeof (val) * CHAR_BIT)
> Though, as val is unsigned HOST_WIDE_INT, we already have a macro for that,
> so if (part * BITS_PER_UNIT == HOST_BITS_PER_WIDE_INT) ?
I went with the last suggestion, thanks for the review.
Patch committed to trunk, no test-case required.
Marking resolved-fixed.
More information about the Gcc-bugs
mailing list