Hard
The same function with and without restrict
These two C functions differ only in whether the parameters are restrict-qualified. Compiled with -O2, does the second statement have to re-read *in from memory in each?
alias.c
// (A) no restrict
void bump(int* in, int* out) {
*out = *in + 1;
*out = *in + 2; // does the compiler need to reload *in here?
}
// (B) restrict
void bumpR(int* restrict in, int* restrict out) {
*out = *in + 1;
*out = *in + 2; // does the compiler need to reload *in here?
}28 of 44 in Compilers