/** *Methodwithanoutercountableloopandaninnerdo-whileloop. *Sinceallworkisdoneintheheaderoftheinnerloop,anyinvarianthoisting *anddeoptingshouldbedoneinitsproperlooppreheader,notthetrue-block *ofthenewlygeneratedtaken-testafterdynamicBCE.
*/ publicstaticint doit(int[][] x, int j) { float f = 0; int acc = 0; for (int i = 0; i < 2; i++) { // The full body of a do-while loop is the loop header. do { // Some "noise" to avoid hoisting the array reference // before the dynamic BCE phase runs.
f++; // The invariant array reference with corresponding bounds check // is a candidate for hoisting when dynamic BCE runs. If it is // not moved to the proper loop preheader, the wrong values // cause the test to fail.
acc += x[i][i];
} while (++j < i);
} return acc;
}
/** *Singlecountableloopwithaclearheaderandaloopbody.Inthiscase, *afterdynamicbce,someinvarianthoistinganddeoptingmustgotothe *properlooppreheaderandsomemustgotothetrue-block.
*/ publicstaticint foo(int[] x, int[] y, int n) { float f = 0; int acc = 0; int i = 0; while (true) { // This part is the loop header. // Some "noise" to avoid hoisting the array reference // before the dynamic BCE phase runs.
f++; // The invariant array reference with corresponding bounds check // is a candidate for hoisting when dynamic BCE runs. If it is // not moved to the proper loop preheader, the wrong values // cause the test to fail.
acc += y[0]; if (++i > n) break; // From here on, this part is the loop body. // The unit-stride array reference is a candidate for dynamic BCE. // The deopting appears in the true-block.
acc += x[i];
} return acc;
}
/** *Anartificialexamplewithaninconsistentphistructureduring *dynamicbcethatiscorrectedafterwards.Notethatonlythelast *assignmentisreallylive,buttheotherstatementssetupan *interestingphistructure.
*/ privatestaticint doit(int[] z) { int a = 0; for (int i = 0; i < 10; ++i) { for (int j = i; j < 10; ++j) {
a = z[i]; for (int k = 0; k < 10; ++k) {
a += z[k];
a = z[i];
}
}
} return a;
}
/** *ExampleshowsthatwecanhoistArrayGettopre-headeronlyif *itsexecutionisguaranteed.
*/ publicstaticint hoistcheck(int[] c) { int i = 0, i2 = 0, i3 = 0, k = 0; int n = c.length; for (i = -100000000; i < 20; i += 10000000) {
i3 = i;
i2 = 0; while (i2++ < 1) { if (i3 >= 0 && i3 < n) {
k += c[i3];
}
}
} return k;
}
publicstaticvoid main(String args[]) { int[][] x = newint[2][2]; int y;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.