Closed agpar closed 7 years ago
iload_0 ldc 10 if_icmplt true_2 iconst_0 goto stop_3 true_2: iconst_1 stop_3: ifeq stop_1 iload_2 iload_2 imul istore_2 iinc 1 1 goto start_0 stop_1: return
In the above, on line 4 a 0 is put on the stack then we branch to stop_3, stop 3 checks if there is a 0 on the stack, then branches to stop_1 if so. Thus, we should optimise as follows:
stop_3
iload_0 ldc 10 if_icmplt true_2 goto stop_1 true_2: iconst_1 stop_3: ifeq stop_1 iload_2 iload_2 imul istore_2 iinc 1 1 goto start_0 stop_1: return
This thing does it: 889af767d75886419d9aa4424703dc63a183016a
In the above, on line 4 a 0 is put on the stack then we branch to
stop_3
, stop 3 checks if there is a 0 on the stack, then branches to stop_1 if so. Thus, we should optimise as follows: