Example 2: A compiler designer is trying to decide between two code sequences for a…
- User
Example 2: A compiler designer is trying to decide between two code sequences for a particular computer. The hardware designers have supplied the following facts: The instructions can be divided into three classes according to their CPI (class A, B, and C). Their respective CPI values are 1, 2, and 3. For a particular high-level language statement, the compiler writer is considering two code sequences that require the following instruction counts: Code seq. 1: A - 2, B - 1, C - 2 Code seq. 1: A - 4, B - 1, C - 1 Which code sequence executes the most instructions? Which will be faster?What is the CPI for each sequence?
- Assistant
Let's analyze both code sequences based on the given information:
Instruction Classes and Their CPI:
- Class A: CPI = 1
- Class B: CPI = 2
- Class C: CPI = 3
Code Sequences:
-
Code Sequence 1:
- Class A: 2 instructions
- Class B: 1 instruction