Branch removal

Patrick Metzler Patrick.Metzler at gmx.net
Mon Oct 1 05:05:16 PDT 2012


Hi,

thank you for the hint, Vladimir.

 > Add flags -XX:+PrintCompilation -XX:+PrintInlining (and may be
 > -XX:-TieredCompilation to look only on C2 compilations). Could be one of
 > inlined method has loop. The graph could be also complicated if it is
 > OSR compilation (there is % next to compilation number in
 > PrintCompilation output).

I did not observe any OSR compilation. But it turned out that in the 
original version:

  > for (E e : arrayList) {
  >    aSwap = a.getCopy();
  >    aSwap.do();
  >    if (e.condition())
  >      a = aSwap;
  > }

the 'if' statement does not get a CFG diamond after parsing both with 
and without -XX:CompileOnly="that method". Also in the modified version

  > aSwap = a.getCopy();
  > for (E e : arrayList) {
  >    aSwap.do();
  >    if (e.condition())
  >      a = aSwap;
  >    aSwap = a.getCopy();
  > }

the 'if' statement does not get a CFG diamond if inlined (and it does if 
executed with -XX:CompileOnly).

I think I will disable inlining with -XX:-Inline for my experiments. If 
I have the time, I will try to remove the branching even if it is not a 
CFG diamond. I would try to eliminate the 'if' statement branching by 
setting the condition to a constant value (and igvn.optimize() will 
remove the dead branch). Then, I would insert the CMove with that 
condition before the use of the local variable, i.e. CallStaticJava for 
aSwap.do().

Best regards,
Patrick


More information about the hotspot-compiler-dev mailing list