RFR: 8292761: x86: Clone nodes to match complex rules

Quan Anh Mai duke at openjdk.org
Tue Aug 23 09:15:24 UTC 2022


On Tue, 23 Aug 2022 09:07:54 GMT, Quan Anh Mai <duke at openjdk.org> wrote:

> Hi,
> 
> This patch tries to clone a node if it can be matched as a part of a BMI and lea pattern. This may reduce the live range of a local or remove that local completely.
> 
> Please take a look and have some reviews. Thanks a lot.

The patch also shows some improvements regarding benchmarking. The results are as follow:

                                          Before           After
    Benchmark            Mode  Cnt    Score    Error    Score   Error  Units
    CloneNodes.testAndn  avgt   15  374.854 ±  1.439  283.440 ± 3.011  ns/op
    CloneNodes.testLea   avgt   15  448.468 ± 10.071  305.273 ± 1.973  ns/op

The benchmark code is:

    @BenchmarkMode(Mode.AverageTime)
    @OutputTimeUnit(TimeUnit.NANOSECONDS)
    @State(Scope.Benchmark)
    @Warmup(iterations = 5, time = 1)
    @Measurement(iterations = 5, time = 1)
    @Fork(3)
    public class CloneNodes {
        static final int[] x = new int[1024];
        int y, z;

        @Benchmark
        public void testLea(Blackhole bh) {
            for (int i = 0; i < x.length; i++) {
                int temp = x[i] << 2;
                bh.consume(temp + 3);
                bh.consume(temp + 7);
            }
        }

        @Benchmark
        public void testAndn(Blackhole bh) {
            int y = this.y; int z = this.z;
            for (int i = 0; i < x.length; i++) {
                int temp = ~x[i];
                bh.consume(temp & y);
                bh.consume(temp & z);
            }
        }
    }

I am not sure if this should be included in the patch or it can be included in another existing one. Please let me know your opinions, thanks a lot.

-------------

PR: https://git.openjdk.org/jdk/pull/9977


More information about the hotspot-compiler-dev mailing list