cpu_neon.c 600 B

12345678910111213141516171819
  1. #ifdef _MSC_VER
  2. #include <Intrin.h>
  3. #endif
  4. #include <arm_neon.h>
  5. int main(int argc, char **argv)
  6. {
  7. // passing from untraced pointers to avoid optimizing out any constants
  8. // so we can test against the linker.
  9. float *src = (float*)argv[argc-1];
  10. float32x4_t v1 = vdupq_n_f32(src[0]), v2 = vdupq_n_f32(src[1]);
  11. int ret = (int)vgetq_lane_f32(vmulq_f32(v1, v2), 0);
  12. #ifdef __aarch64__
  13. double *src2 = (double*)argv[argc-2];
  14. float64x2_t vd1 = vdupq_n_f64(src2[0]), vd2 = vdupq_n_f64(src2[1]);
  15. ret += (int)vgetq_lane_f64(vmulq_f64(vd1, vd2), 0);
  16. #endif
  17. return ret;
  18. }