Computer Laboratory

Course pages 2016–17

Optimising Compilers

Here I'll post a list of questions that have been asked about the course, whose answers may be useful to everyone.

Don't you have to consider overflow in your liveness / expression availability example?

This refers to the 11th slide from both lecture 3 and lecture 4 where we have the following code structure:

  ...
  if ((x+1)*(x+1) == y) {
    ...
  }
  if (x*x + 2*x + 1 != y) {
    ...
  }
  ...

This is used to demonstrate the difference between semantic and syntactic liveness or expression availability. The idea is that the second if-statement has the brackets expanded and the condition reversed, therefore only one of these if-statements will be true. However, it is making the simplifying assumption that it is computing on values that won't overflow, which is the case in C when computing with unsigned integers because the standard dictates that they wrap around (see §6.2.5:9 in the final C11 draft if you're interested).