Question 3
The following code adds a scalar to a vector:
For (i=999; i>=0; i=i-1)
X[i] = x[i] + s;
which translates in RISC-V code as:
Loop:
fld f0, 0(x1)
fadd.d f4, f0, f2 // f2 has the scalar value s
fsd f4, 0(x1)
addi x1, x1, -8
bne x1, x2, loop // regs[x2]+8 is the add of the last element
a) One way to exploit ILP is loop unrolling, do unroll the above loop to 4 copies of the body.