我想在 ARM 处理器上处理大量浮点数,使用 Neon 技术一次计算四个浮点数。对于加法和乘法等运算来说一切都很好,但是如果我的计算进入 IF 块,我该怎么办?例子:
// In the non-vectorized original code, A is an array of many floating-point
// numbers, which are calculated one at a time. Now they're packed
// into a vector and processed four at a time
...calculate A...
if (A > 10.f)
{
A = A+5.f;
}
else
{
A = A+10.f;
}
Run Code Online (Sandbox Code Playgroud)
现在,我要执行哪个 IF 分支?如果正在处理的向量中的某些值大于 10 而某些值小于 10,该怎么办?是否有可能像这样矢量化代码?