RFR: 8291649: multiple tests failing with -Xcomp after JDK-8290034 [v2]
John R Rose
jrose at openjdk.org
Thu Aug 25 21:06:03 UTC 2022
On Wed, 24 Aug 2022 05:02:13 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>> Jatin Bhateja has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8291649: Review comments resolutions.
>
> src/hotspot/share/utilities/moveBits.hpp line 63:
>
>> 61: /*****************************************************************************
>> 62: * GCC and compatible (including Clang)
>> 63: *****************************************************************************/
>
> Is it really worth the extra code to allow the use of the gcc builtins?
Kim, is there a way to do this in less code?
Seems to me that something like this could work:
template<typename T, size_t S>
T reverse_bytes(T x) {
if (size == 1) return x;
T alt8bs = (T)((uint64_t)-1 / 0xFFFF * 0xFF); // 0x00FF…00FF
x = ((x & alt8bs) << 8) | (((uint64_t)x >> 8 & alt8bs);
if (size == 2) return x;
T alt16bs = (T)((uint64_t)-1 / 0xFFFFFFFFll * 0xFFFF); // 0x0000FFFF…0000FFFF
…
}
That is, one function bodies handles cases for 1/2/4/8 byte values.
Could it be just a function template, with an explicit instantiation (overriding the general template) where it matches an intrinsic?
-------------
PR: https://git.openjdk.org/jdk/pull/9987
More information about the hotspot-compiler-dev
mailing list