我正在将一个应用程序从Altivec移植到Neon。
我在Altivec中看到了许多返回标量值的本质。
我们手臂上有这样的内蕴吗?
例如,vec_all_gt
发布于 2022-03-23 08:54:10
没有给出标量比较结果的本质。这是因为SIMD比较的常见模式是使用无分支的车道掩蔽和条件选择来实现多重结果,而不是基于分支的控制流。
如果你需要的话,你可以建造它们.
// Do a comparison of e.g. two vectors of floats
uint32x4_t compare = vcgeq_f32(a, b)
// Shift all compares down to a single bit in the LSB of each lane, other bits zero
uint32x4_t tmp = vshrq_n_u32(a.m, 31);
// Shift compare results up so lane 0 = bit 0, lane 1 = bit 1, etc.
static const int shifta[4] { 0, 1, 2, 3 };
static const int32x4_t shift = vld1q_s32(shifta);
tmp = vshlq_u32(tmp, shift)
// Horizontal add across the vector to merge the result into a scalar
return vaddvq_u32();..。此时,您可以定义any() (掩码为非零)和all() (掩码为0xF)比较(如果需要分支逻辑)。
https://stackoverflow.com/questions/71574662
复制相似问题