[BUG] Incorrect aarch64 instruction called for vpadd_f32 intrinsic
Description
When vpadd_f32 intrinsic is indirectly called the int32 opcode is used instead of the fp32 one.
In other words I get : 0ea1bc00 addp v0.2s, v0.2s, v1.2s instead of 2e21d400 faddp v0.2s, v0.2s, v1.2s
Minimal reproduction example:
#include <iostream>
#include <arm_neon.h>
inline float32x2_t addp(const float32x2_t &a, const float32x2_t &b)
{
return vpadd_f32(a,b);
}
int main(int argc, char** argv)
{
float32x2_t a = vdup_n_f32(2.f);
float32x2_t b = vdup_n_f32(3.f);
auto res = addp(a, b);
std::cout << vget_lane_f32(res, 0) << std::endl;
}
Build command:
clang++ test.cpp -std=gnu++11 -g -O0 -pie -o test
This happens only in debug mode. In release mode (function inline) or in case of directly using the intrinsic the generated opcode seems to be fine.
Environment Details
- NDK Version: For r18b and after (Working on r17c)
- Host OS: Linux
This seems to be the same as upstream issue https://bugs.llvm.org//show_bug.cgi?id=40968. The fix is in r21's clang.
@DanAlbert @pirama-arumuga-nainar yes this looks to be the same issue. Thanks a lot.
Hello @pirama-arumuga-nainar I tried with the latest ndk: https://dl.google.com/android/repository/android-ndk-r21-beta2-linux-x86_64.zip and I still find the "vpadd_f32" problem with our main project.
Also (probably an unrelated problem) if I try to compile and run the "Minimal reproduction example", I get the following error: CANNOT LINK EXECUTABLE "./test-r21-beta2": cannot locate symbol "_Unwind_Resume" referenced by "/data/local/tmp/manbot01/test-r21-beta2"...
Thanks Manuel (If I don't see a reply I will reopen the issue)
@ManubARM Can you double check at your end? I see the faddp in the output.
$ android-ndk-r21-beta2/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -std=gnu++11 -target aarch64-linux-android -g -O0 -pie -c vpadd.cpp
$ android-ndk-r21-beta2/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-objdump -Dx vpadd.o | grep addp
...
2c: 2e21d400 faddp v0.2s, v0.2s, v1.2s
...
It took me some time but yeah, it is fine for ndk-r21 and ndk-21-beta2 Sorry Manuel
No worries. Thanks for checking.