Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 771351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:38:26+00:00 2026-05-14T18:38:26+00:00

I’m making a vector/matrix library. (GCC, ARM NEON, iPhone) typedef struct{ float v[4]; }

  • 0

I’m making a vector/matrix library. (GCC, ARM NEON, iPhone)

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

I passed struct data as pointer to avoid performance degrade from data copying when calling function. So I designed function like this at first:

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

But, if function is inline, is there any reason to pass values as pointer for performance? Do those variables being copied too? How about register and caches? I tried to redesign function like this:

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

How do you think about calling costs of each cases?

  • I added ‘const’ to 2nd signature to reflect suggestions.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:38:26+00:00Added an answer on May 14, 2026 at 6:38 pm

    When the function is inline typically no copying of variables is directly involved with the call. Variables will still be moved around and put on the stack sometimes as a normal part of execution but not as a direct result of the function call. (When you run out of registers, some values may get put on the stack, etc… but only if needed.) So the overhead of the “call” basically disappears when a function is inlined (No more setting up/tearing down the stack frame, no more unconditional jump, no more pushing/poping parameters.)

    If you can rely on your always_inline attribute to always inline the function, then you should also not pass the Vector by pointer (if it isn’t modified). The reason for this is that passing it by pointer requires the vector’s address be taken, which means that the compiler must ensure that it has an address and thus it cannot exist only in CPU registers. This can slow things down if it isn’t needed, and when you take the address of something the compiler will always ensure it has an address because the compiler can’t be sure the address isn’t needed.

    Because of the pass-by-pointer, this code will ALWAYS have an instruction to get the object’s address, and at least one dereference to get at a member’s value. If you pass-by-value then this MAY still happen, but the compiler MAY be able to optimize all of that away.

    Don’t forget that overuse of inlining can significantly increase the size of the compiler binary code. In certain cases having large code segments (as a result of inline functions) can cause more instruction cache misses with will result in slower performance because the CPU is constantly having to go out to main memory to fetch parts of your program because some of it is too big to fit in the small L1 cache. This may be especially important in embedded processors (like the iPhone) because these processors typically have small caches.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 374k
  • Answers 374k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer irb> my_array.sort_by { |e| [ e == 'chicken' ? 0… May 14, 2026 at 7:57 pm
  • Editorial Team
    Editorial Team added an answer Take a look at ASP.NET MVC 2.0 areas http://www.asp.net/mvc/videos/aspnet-mvc-2---areas That… May 14, 2026 at 7:57 pm
  • Editorial Team
    Editorial Team added an answer Git gives you version control, Dropbox gives you gratis private… May 14, 2026 at 7:57 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.