hmm lets see
int arr[20];
int func1(int i) {
*(arr+i) = 10;
}
int func2(int i) {
arr[i] = 10;
}
int main() {
func1(9);
func2(9);
}
compile this and run it using gdb
disassemble func1 gives
Dump of assembler code for function func1:
0x08048334 <func1+0>: push %ebp
0x08048335 <func1+1>: mov %esp,%ebp
0x08048337 <func1+3>: mov 0x8(%ebp),%eax
0x0804833a <func1+6>: movl $0xa,0x8049580(,%eax,4)
0x08048345 <func1+17>: leave
0x08048346 <func1+18>: ret
0x08048347 <func1+19>: nop
disassemble func2 gives
Dump of assembler code for function func2:
0x08048348 <func2+0>: push %ebp
0x08048349 <func2+1>: mov %esp,%ebp
0x0804834b <func2+3>: mov 0x8(%ebp),%eax
0x0804834e <func2+6>: movl $0xa,0x8049580(,%eax,4)
0x08048359 <func2+17>: leave
0x0804835a <func2+18>: ret
0x0804835b <func2+19>: nop
End of assembler dump.
Now spot the difference (I cannot)
you can see that the compiler produces the exact same code. so dont expect any change in performance
.
you can check on other arch too.