cpu_vxe.c 788 B

12345678910111213141516171819202122232425
  1. #if (__VEC__ < 10302) || (__ARCH__ < 12)
  2. #error VXE not supported
  3. #endif
  4. #include <vecintrin.h>
  5. int main(int argc, char **argv)
  6. {
  7. __vector float x = vec_nabs(vec_xl(argc, (float*)argv));
  8. __vector float y = vec_load_len((float*)argv, (unsigned int)argc);
  9. x = vec_round(vec_ceil(x) + vec_floor(y));
  10. __vector bool int m = vec_cmpge(x, y);
  11. x = vec_sel(x, y, m);
  12. // need to test the existence of intrin "vflls" since vec_doublee
  13. // is vec_doublee maps to wrong intrin "vfll".
  14. // see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100871
  15. #if defined(__GNUC__) && !defined(__clang__)
  16. __vector long long i = vec_signed(__builtin_s390_vflls(x));
  17. #else
  18. __vector long long i = vec_signed(vec_doublee(x));
  19. #endif
  20. return (int)vec_extract(i, 0);
  21. }