Built-in function and call cost in C

I am creating a vector / matrix library. (GCC, ARM NEON, iPhone)

typedef struct{ float v[4]; } Vector;
typedef struct{ Vector v[4]; } Matrix;

I passed the structure data as a pointer to avoid performance degradation when copying data when calling a function. Therefore, I first developed such a function:

void makeTranslation(const Vector* factor, Matrix* restrict result);

But, if the function is built-in, is there any reason to pass values ​​as a pointer to performance? Are these variables copied? What about register and caches? I tried to change the function as follows:

inline Matrix makeTranslation(const Vector factor) __attribute__ ((always_inline));

What do you think about the allocation of costs for each case?

  • I added 'const' for the second signature to reflect the suggestions.
+3
source share
1 answer

, , . , . ( , ..... .) , "" , ( / , , / .)

always_inline, , ( ). , , , , , , . , , -, , , , .

- . , , .

, . ( ) , , , , L1. (, iPhone), .

+3

Source: https://habr.com/ru/post/1743626/


All Articles