[PATCH LoongArch v3 0/5] Add LoongArch support.
H.J. Lu
hjl.tools@gmail.com
Mon Oct 25 18:04:50 GMT 2021
On Sun, Oct 24, 2021 at 5:33 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Sun, Oct 24, 2021 at 05:15:27AM -0700, H.J. Lu via Binutils wrote:
> > Please fix unexpected failures and unexpected successes. New port
> > should have a clean "make check".
>
> Yes, that would be good. There are also some more ubsan errors that
Please fix
https://sourceware.org/bugzilla/show_bug.cgi?id=28497
> show up when running the testsuite. For example:
>
> opcodes/loongarch-coder.c:111:11: runtime error: left shift of 16383 by 18 places cannot be represented in type 'int'
> opcodes/loongarch-coder.c:136:8: runtime error: shift exponent 32 is too large for 32-bit type 'unsigned int'
> opcodes/loongarch-coder.c:144:9: runtime error: shift exponent 32 is too large for 32-bit type 'unsigned int'
>
> The first one is on this code
> if (si)
> {
> ret <<= sizeof (ret) * 8 - len;
> ret >>= sizeof (ret) * 8 - len;
> }
>
> ubsan doesn't complain about the shift right, but note that according
> to the ISO C99 standard right shifting signed types with negative
> values is implementation defined. I've used compilers for
> microprocessors back in the 1980s that always did logical right shift,
> because the micro didn't have arithmetic right shift! So, strictly
> speaking, you may not get the desired sign extension. The following
> is better (you may not need the len != 0 test, I didn't check whether
> len can be 0).
>
> if (si && len != 0)
> {
> uint32_t sign = 1u << (len - 1);
> ret = (ret ^ sign) - sign;
> }
>
> --
> Alan Modra
> Australia Development Lab, IBM
--
H.J.
More information about the Binutils
mailing list