Chapter 8: Intermediate Code Generation

Short Circuit Evaluation of boolean expressions

. Translate boolean expressions without:

- generating code for boolean operators

- evaluating the entire expression

. Flow of control statements

S if E then S1

| if E then S1 else S 2

| while E do S 1

We can translate a boolean expression into three-address code without generating code for boolean operators and without evaluating the entire expression. Take the case of the previous example, here we can tell the value of t by whether we reach statement 101 or 103, so the value of t becomes redundant. Similarly, for larger expressions the value can be determined without having to evaluate the expression completely. However, if a part of the expression having a side effect is not evaluated, the side effect will not be visible.