1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#include "test.h"
typedef int int4 __attribute__((vector_size(16)));
int4 sub_int_vectors(int4 a, int4 b) {
return a - b;
}
int main() {
int4 a = {100, 200, 300, 400};
int4 b = {10, 20, 30, 40};
int4 c;
c = sub_int_vectors(a, b);
for (int i = 0; i < 4; i++) {
printf("c[%d] = %d\n", i, c[i]);
}
ASSERT(90, c[0]);
ASSERT(180, c[1]);
ASSERT(270, c[2]);
ASSERT(360, c[3]);
int4 d = sub_int_vectors(c, b);
for (int i = 0; i < 4; i++) {
printf("d[%d] = %d\n", i, d[i]);
}
ASSERT(80, d[0]);
ASSERT(160, d[1]);
ASSERT(240, d[2]);
ASSERT(320, d[3]);
return 0;
}
|