[aarch64-port-dev ] 8136820: Generate better code for some Unsafe addressing patterns

Andrew Haley aph at redhat.com
Wed Sep 30 09:46:27 UTC 2015


This report is for an x86 code generation improvement.

I checked, and our code is already optimal:

    static int[] array;
    static long base;
    static int test1() {
        int res = 0;
        for (int i = 0; i < 100; i++) {
            long address = (((long) i) << 2) + base;
            res += UNSAFE.getInt(array, address);
        }
        return res;
    }

$ ./hs-comp/build/linux-aarch64-normal-server-slowdebug/jdk/bin/java -Xbootclasspath/p:/home/aph/NetBeansProjects/Tests/build/classes -XX:LoopMaxUnroll=0 tests.Tests


 ;; B2: #	B2 B3 <- B1 B2 	Loop: B2-B2 inner  Freq: 101.007

  0x000003ff70468b40: ldr	w11, [x10,w12,sxtw #2]
  0x000003ff70468b44: add	w12, w12, #0x1  ;*iinc
                                                ; - tests.Tests::test1 at 32 (line 22)

  0x000003ff70468b48: add	w0, w0, w11     ;*iadd
                                                ; - tests.Tests::test1 at 30 (line 24)

  0x000003ff70468b4c: cmp	w12, #0x64
  0x000003ff70468b50: b.lt	0x000003ff70468b40  ;*if_icmpge
                                                ; - tests.Tests::test1 at 7 (line 22)

(Having said that, we could vectorize it, but that's something for another day.)

Andrew.


More information about the aarch64-port-dev mailing list