If your compiler can't see that these two bits of code have identical effects, it's a piece of junk and you shouldn't use it.
But your argument is nonsense. Here's what a naive implementation of the two would do:
1: int myFunction(const int &a) { return 2 + a; }
Pass the address of a
. Get the value from that address. Add two to it. Return it.
2: int myFunction(int a) { return 2 + a; }
Pass a
's value. Add two to it. Return it.
Notice the second one avoids two operations -- getting a
's address and then getting a
's value from that address. Worse, the first one only works if a
is stored in memory, which means it will have to be stored in memory if it's not already there. Ouch.
For a mere thousand calls a second, it's not going to make much difference. But for the more complicated cases where the compiler may not be able to see everything at once, it's standard practice to pass "small" types by value. You only want to pass by reference when the cost of the extra indirection is less than the cost of copying the value.