Another Guarding Example
I = get_initial_I();while (I > 0) loop instrA, instrB, instrC I--;end loop;
No guarding: r1 = get_initial_I(); Bz r1, skipLTop: instrA, instrB, instrC r1 = r1 - 1; bnz r1, LTop skip: instrD….
I = get_initial_I();while (I > 0) loop instrA, instrB, instrC I--;end loop;
guarding: r1 = get_initial_I();LTop: True(r1) instrA True(r1) instrB True(r1) instrC True(r1) r1 = r1 - 1; True(r1) jmp LTop instrD….
Note that guarding did not eliminate jump at bottom of loop. Also, if R1 is initially zero, instructions are still fetched.