mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Use native CRC instructions on 64-bit LoongArch
As with the Intel and Arm CRC instructions, compiler intrinsics for them must be supported by the compiler. In contrast, no runtime check is needed. Aligned memory access is faster, so use the Arm coding as a model. YANG Xudong Discussion: https://postgr.es/m/b522a0c5-e3b2-99cc-6387-58134fb88cbe%40ymatrix.cn
This commit is contained in:
24
meson.build
24
meson.build
@ -2065,6 +2065,30 @@ int main(void)
|
||||
cdata.set('USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK', 1)
|
||||
have_optimized_crc = true
|
||||
endif
|
||||
|
||||
elif host_cpu == 'loongarch64'
|
||||
|
||||
prog = '''
|
||||
int main(void)
|
||||
{
|
||||
unsigned int crc = 0;
|
||||
crc = __builtin_loongarch_crcc_w_b_w(0, crc);
|
||||
crc = __builtin_loongarch_crcc_w_h_w(0, crc);
|
||||
crc = __builtin_loongarch_crcc_w_w_w(0, crc);
|
||||
crc = __builtin_loongarch_crcc_w_d_w(0, crc);
|
||||
|
||||
/* return computed value, to prevent the above being optimized away */
|
||||
return crc == 0;
|
||||
}
|
||||
'''
|
||||
|
||||
if cc.links(prog, name: '__builtin_loongarch_crcc_w_b_w, __builtin_loongarch_crcc_w_h_w, __builtin_loongarch_crcc_w_w_w, and __builtin_loongarch_crcc_w_d_w',
|
||||
args: test_c_args)
|
||||
# Use LoongArch CRC instruction unconditionally
|
||||
cdata.set('USE_LOONGARCH_CRC32C', 1)
|
||||
have_optimized_crc = true
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
if not have_optimized_crc
|
||||
|
Reference in New Issue
Block a user