RFR(S): 8149745: C2 should optimize long accumulations in a counted loop

Roland Westrelin roland.westrelin at oracle.com
Fri Feb 12 15:53:17 UTC 2016


http://cr.openjdk.java.net/~roland/8149745/webrev.00/

This extends the code that looks for a parallel induction variable to long accumulations so in the following code:

public static long testLongAcc() {
   long acc = 0;

   for (int i = 0; i < 1000; i++) {
       acc += 8;
   }

   return acc;
}

the loop is optimized out.

What I find puzzling is that code for integer accumulations doesn’t try to estimate the benefit of turning one AddI into a more expensive MulI + AddI. Maybe it’s too unpredictable but in the case of the long accumulations would we want to check that, for instance, the long Phi has no use in the loop?

Roland.




More information about the hotspot-compiler-dev mailing list