On 6/5/24 20:36, maobibo wrote:
static biz_accel_fn const accel_table[] = {
buffer_is_zero_int_ge256,
#ifdef __loongarch_sx
buffer_is_zero_lsx,
#endif
#ifdef __loongarch_asx
buffer_is_zero_lasx,
#endif
};
static unsigned best_accel(void)
{
#ifdef __loongarch_asx
/* lasx may be index 1 or 2, but always last */
return ARRAY_SIZE(accel_table) - 1;
#else
/* lsx is always index 1 */
return 1;
#endif
}
size of accel_table is decided at compile-time, will it be better if runtime checking is
added also? something like this:
unsigned info = cpuinfo_init();
#ifdef __loongarch_asx
if (info & CPUINFO_LASX) {
/* lasx may be index 1 or 2, but always last */
return ARRAY_SIZE(accel_table) - 1;
}
#endif
No, because the ifdef checks that the *compiler* is prepared to use LASX/LSX instructions
itself without further checks. There's no point in qemu checking further.
r~