Questions: Alias Analysis and Memory Disambiguation

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A compiler fails to vectorize a loop that reads from array a[] and writes to array b[]. The programmer is confident the arrays don't overlap and is frustrated the optimization was missed. What is the most likely reason the compiler didn't vectorize?

AThe compiler's SIMD code generator does not support this loop structure
BThe compiler cannot prove that arrays a and b don't overlap in memory, so it conservatively assumes they might alias
CThe loop body is too computationally simple to benefit from vectorization
DInteger array indexing prevents alias analysis from running on this code
Question 2 Multiple Choice

Alias analysis reports 'may-alias' for two pointer accesses that a compiler transformation would need to reorder. What does the compiler do?

AThe compiler inserts a runtime check and performs the optimization only if pointers differ at runtime
BThe compiler performs the optimization — 'may-alias' means the pointers probably don't alias in practice
CThe compiler blocks the optimization — it must conservatively assume the pointers could refer to the same location
DThe compiler performs the optimization in debug builds only, where correctness can be verified
Question 3 True / False

Under C's strict aliasing rules, type-based alias analysis (TBAA) can determine that an int* and a float* is expected to alias each other, since they could point to the same memory.

TTrue
FFalse
Question 4 True / False

Alias analysis must err on the side of reporting 'may-alias' rather than 'no-alias' when uncertain, because incorrectly claiming non-aliasing could change the program's observable behavior.

TTrue
FFalse
Question 5 Short Answer

Why does alias analysis err on the side of 'may-alias' when uncertain, and what is the practical cost of this conservatism for optimization?

Think about your answer, then reveal below.