Created
June 11, 2021 14:23
-
-
Save malfet/c612c9f4b3b5681ca1b2a69930825871 to your computer and use it in GitHub Desktop.
Implements trunc using vcvtq vs vrndq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <arm_neon.h> | |
#include <iostream> | |
int main(void) { | |
const float inp[4] = { 3.1, 2.7, -2.9, -1.0000000200408773e+20 }; | |
std::cout << "inp= " << inp[0] << " " << inp[1] << " " << inp[2] << " " << inp[3] << std::endl; | |
float32x4_t f = vld1q_f32(inp); | |
float32x4_t old_trunc = vcvtq_f32_s32(vcvtq_s32_f32(f)); | |
float32x4_t new_trunc = vrndq_f32(f); | |
float out[4]; | |
vst1q_f32(out, old_trunc); | |
std::cout << "old_trunc= " << out[0] << " " << out[1] << " " << out[2] << " " << out[3] << std::endl; | |
vst1q_f32(out, new_trunc); | |
std::cout << "new_trunc= " << out[0] << " " << out[1] << " " << out[2] << " " << out[3] << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment