Compilers

Which kind of instruction does a compiler's automatic vectorization use?

  1. AInstructions that raise interrupts
  2. BSIMD instructions handling multiple data at once
  3. CInstructions that erase the entire contents of the cache at once
Show answer and explanation

Answer: B. SIMD instructions handling multiple data at once

Automatic vectorization finds loops that perform the same computation on each array element and replaces them with SIMD instructions that process several elements at once. A 128-bit SIMD register can add four 32-bit numbers simultaneously, potentially cutting the loop's operation count to a quarter. Conditions include no dependences between iterations and contiguous data, and possible pointer overlap can cause the compiler to give up. Interrupt or cache-management instructions are unrelated.

  • A. Interrupt-raising instructions are not used.
  • B. Correct. SIMD instructions process multiple elements together.
  • C. It has nothing to do with cache-clearing instructions.
Practice this topic Back to topic

More Compilers questions

  1. What basic condition must compiler optimizations respect?
  2. Which describes instruction selection, one stage of code generation?
  3. Which describes a cross compiler?
  4. When debugging a program compiled with optimization, some variables may show as "unavailable." What is the main reason?
  5. After thoroughly applying constant propagation, constant folding and dead-code elimination to the function above, what does it return and what code remains?