In the attached program Foo.java, The C2-generated x86_64 code performs the test cmpl RSI, #1 twice in adjacent blocks. The second cmpl is redundant and could be just removed.
$ java -Xcomp -XX:-TieredCompilation -XX:CompileOnly=Foo::foo -XX:+PrintOptoAssembly -XX:LoopUnrollLimit=0 Foo.java
(..)
033 cmpl RSI, #1
036 je,s B5 P=0,200000 C=1,000000
038 B2: # out( B5 B3 ) <- in( B1 ) Freq: 0,8
038 cmpl RSI, #1
(..)
The assembly-level CFG is attached for clarity.
$ java -Xcomp -XX:-TieredCompilation -XX:CompileOnly=Foo::foo -XX:+PrintOptoAssembly -XX:LoopUnrollLimit=0 Foo.java
(..)
033 cmpl RSI, #1
036 je,s B5 P=0,200000 C=1,000000
038 B2: # out( B5 B3 ) <- in( B1 ) Freq: 0,8
038 cmpl RSI, #1
(..)
The assembly-level CFG is attached for clarity.