Irreducible loop

Control-flow graph

(a) an if-then-else
(b) a while loop
(c) a natural loop with two exits, e.g. while with an if…break in the middle; non-structured but reducible
(d) an irreducible CFG: a loop with two entry points, e.g. goto into a while or for loop

Java case

IrreducibleLoop.java

public class IrreducibleLoop {
    public static void test(int loop) {
    }
}

IrreducibleLoop.jasm

super public class IrreducibleLoop
    version 63:0
{
  public Method "<init>":"()V" 
    stack 1 locals 1
  {
        aload_0;
        invokespecial    Method java/lang/Object."<init>":"()V";
        return;
  }
  public static Method test:"(I)V" 
    stack 2 locals 2
  {
    L0: iconst_0;
        istore_1;
        iload_0;
        ifne    L2;
    L1: stack_frame_type append;
        locals_map int;
        iload_1;
        iload_0;
        if_icmpge    L3;
    L2: stack_frame_type same;
        goto    L1;
    L3: stack_frame_type chop1;
        return;
  }

} // end Class IrreducibleLoop

Main.java

public class Main {
    public static void main(String[] args) {
        for (int i = 0; i < 12000; i++) {
            IrreducibleLoop.test(0);
        }
    }
}

Run

javac Main.java
java -jar asmtools-core-7.0.b10-ea.jar jasm IrreducibleLoop.jasm
java -XX:TieredStopAtLevel=1 -Xcomp -XX:CompileCommand=compileonly,IrreducibleLoop::* Main

Refer

https://en.wikipedia.org/wiki/Control-flow_graph

Float-point fused Multiply-Add AArch64 vs LoongArch64

AA64: fmadd  d, n, m, a: d = a + n * m
LA64: fmadd  d, j, k, a: d = a + j * k

AA64: fmsub  d, n, m, a: d = a + (-n) * m
                         d = a - n * m
                         d = - (n * m - a)
LA64: fnmsub d, j, k, a: d = - (j * k - a)
                         d = a - j * k
                         d = a + (-j) * k

AA64: fnmadd d, n, m, a: d = (-a) + (-n) * m
                         d = - (n * m + a)
LA64: fnmadd d, j, k, a: d = - (j * k + a)
                         d = (-a) + (-n * m)

AA64: fnmsub d, n, m, a: d = (-a) + n * m
                         d = n * m - a
LA64: fmsub  d, j, k, a: d = j * k - a
                         d = (-a) + j * k

Hotspot stress diagnostic options

SafepointALot: Generate a lot of safepoints. This works with GuaranteedSafepointInterval.

HandshakeALot: Generate a lot of handshakes. This works with GuaranteedSafepointInterval.

DeoptimizeALot: Deoptimize at every exit from the runtime system.

ZombieALot: Create zombies (non-entrant) at exit from the runtime system.

WalkStackALot: Trace stack (no print) at every exit from the runtime system.

DeoptimizeObjectsALot: For testing purposes concurrent threads revert optimizations based on escape analysis at intervals given with DeoptimizeObjectsALotInterval=n. The thread count is given with DeoptimizeObjectsALotThreadCountSingle and DeoptimizeObjectsALotThreadCountAll.

DontYieldALot: Throw away obvious excess yield calls.

StringDeduplicationResizeALot: Force more frequent table resizing.

DeoptimizeNMethodBarriersALot: Make nmethod barriers deoptimise a lot.

OpenJDK Guide

Java Virtual Machine Guide: https://docs.oracle.com/en/java/javase/11/vm/native-memory-tracking.html#GUID-710CAEA1-7C6D-4D80-AB0C-B0958E329407

HostSpot Virtual Machine Garbage Collection Tuning Guide: https://docs.oracle.com/en/java/javase/11/gctuning/garbage-collector-implementation.html#GUID-23844E39-7499-400C-A579-032B68E53073

OpenJDK Developers’ Guide: https://openjdk.java.net/guide/index.html

HotSpot Runtime Overview: https://openjdk.java.net/groups/hotspot/docs/RuntimeOverview.html

Java Coding Style: https://www.oracle.com/java/technologies/javase/codeconventions-contents.html

HotSpot Coding Style: https://github.com/openjdk/jdk/blob/master/doc/hotspot-style.md

HotSpot VM Options: https://www.oracle.com/java/technologies/javase/vmoptions-jsp.html

PrintAssembly: https://wiki.openjdk.java.net/display/HotSpot/PrintAssembly

HotSpot Glossary of Terms: https://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html

Building the JDK: https://openjdk.java.net/groups/build/doc/building.html

Building jtreg: http://openjdk.java.net/jtreg/build.html

JVM Allocate Prefetch Options: https://www.opsian.com/blog/jvms-allocateprefetch-options/