Previous | Next --- Slide 33 of 79
Back to Lecture Thumbnails
bob_sacamano

Just to clarify the classroom discussion, the worst case tends to 1/8 in situations where one out the eight paths of execution executes the then clause and the else clause has very few (possibly zero) instructions?

tcm

Yes, that's correct.

cuiwei

In practice, do those red crosses mean no-ops, or the computation is carried out anyway but the results are discarded?

tcm

That's a good question, @cuiwei. Hardware designers have the flexibility to implement these predicated operations in whatever way is most convenient, given that they don't have any side-effects, and they don't cause any exceptions. For example, consider the following code:

if (x != 0) { result = a/x; } else result = 0;

The "then" clause will contain a division operation. However, if x==0, then we do not want to have the divide instruction cause a divide-by-zero exception. Another simple example would be:

if (p != NULL) result = *p;

So it is not just a matter of performing the operation but discarding its result; we don't want it to trigger an exception. For our purposes, it is more useful to think of the instructions as being no-ops.