mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-19 10:34:38 +02:00
8259398: Super word not applied to a loop with byteArrayViewVarHandle
Reviewed-by: vlivanov, thartmann, chagedorn
This commit is contained in:
parent
80760a322b
commit
02d586e13e
2 changed files with 51 additions and 16 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -3893,12 +3893,7 @@ bool SWPointer::scaled_iv(Node* n) {
|
|||
NOT_PRODUCT(_tracer.scaled_iv_6(n, _scale);)
|
||||
return true;
|
||||
}
|
||||
} else if (opc == Op_ConvI2L) {
|
||||
if (n->in(1)->Opcode() == Op_CastII &&
|
||||
n->in(1)->as_CastII()->has_range_check()) {
|
||||
// Skip range check dependent CastII nodes
|
||||
n = n->in(1);
|
||||
}
|
||||
} else if (opc == Op_ConvI2L || opc == Op_CastII) {
|
||||
if (scaled_iv_plus_offset(n->in(1))) {
|
||||
NOT_PRODUCT(_tracer.scaled_iv_7(n);)
|
||||
return true;
|
||||
|
@ -3995,16 +3990,15 @@ bool SWPointer::offset_plus_k(Node* n, bool negate) {
|
|||
}
|
||||
|
||||
if (!is_main_loop_member(n)) {
|
||||
// 'n' is loop invariant. Skip range check dependent CastII nodes before checking if 'n' is dominating the pre loop.
|
||||
// 'n' is loop invariant. Skip ConvI2L and CastII nodes before checking if 'n' is dominating the pre loop.
|
||||
if (opc == Op_ConvI2L) {
|
||||
n = n->in(1);
|
||||
if (n->Opcode() == Op_CastII &&
|
||||
n->as_CastII()->has_range_check()) {
|
||||
// Skip range check dependent CastII nodes
|
||||
}
|
||||
if (n->Opcode() == Op_CastII) {
|
||||
// Skip CastII nodes
|
||||
assert(!is_main_loop_member(n), "sanity");
|
||||
n = n->in(1);
|
||||
}
|
||||
}
|
||||
// Check if 'n' can really be used as invariant (not in main loop and dominating the pre loop).
|
||||
if (invariant(n)) {
|
||||
_negate_invar = negate;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -33,10 +33,14 @@
|
|||
* @run main compiler.vectorization.TestBufferVectorization buffer
|
||||
* @run main compiler.vectorization.TestBufferVectorization bufferHeap
|
||||
* @run main compiler.vectorization.TestBufferVectorization bufferDirect
|
||||
* @run main compiler.vectorization.TestBufferVectorization arrayView
|
||||
*/
|
||||
|
||||
package compiler.vectorization;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.VarHandle;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.IntBuffer;
|
||||
|
@ -51,6 +55,7 @@ public class TestBufferVectorization {
|
|||
final static int offset = buffer.arrayOffset();
|
||||
final static IntBuffer heap_buffer_byte_to_int = ByteBuffer.allocate(N * Integer.BYTES).order(ByteOrder.nativeOrder()).asIntBuffer();
|
||||
final static IntBuffer direct_buffer_byte_to_int = ByteBuffer.allocateDirect(N * Integer.BYTES).order(ByteOrder.nativeOrder()).asIntBuffer();
|
||||
final static VarHandle VH_arr_view = MethodHandles.byteArrayViewVarHandle(int[].class, ByteOrder.nativeOrder()).withInvokeExactBehavior();
|
||||
final static String arch = System.getProperty("os.arch");
|
||||
|
||||
interface Test {
|
||||
|
@ -153,9 +158,42 @@ public class TestBufferVectorization {
|
|||
}
|
||||
}
|
||||
|
||||
static class TestArrayView implements Test {
|
||||
final byte[] b_arr = new byte[N * Integer.BYTES];
|
||||
|
||||
public void init() {
|
||||
for (int k = 0; k < N; k++) {
|
||||
VH_arr_view.set(b_arr, k, k);
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
for (int k = 0; k < b_arr.length; k += 4) {
|
||||
int v = (int) VH_arr_view.get(b_arr, k);
|
||||
VH_arr_view.set(b_arr, k, v + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void verify() {
|
||||
init(); // reset
|
||||
// Save initial INT values
|
||||
final int[] i_arr = new int[N];
|
||||
for (int k = 0; k < i_arr.length; k++) {
|
||||
i_arr[k] = (int) VH_arr_view.get(b_arr, k * Integer.BYTES);
|
||||
}
|
||||
run(); // run compiled code
|
||||
for (int k = 0; k < i_arr.length; k++) {
|
||||
int v = (int) VH_arr_view.get(b_arr, k * Integer.BYTES);
|
||||
if (v != (i_arr[k] + 1)) {
|
||||
throw new RuntimeException(" Invalid result: VH_arr_view.get(b_arr, " + (k * Integer.BYTES) + "): " + v + " != " + (i_arr[k] + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length == 0) {
|
||||
throw new RuntimeException(" Missing test name: array, arrayOffset, buffer, bufferHeap, bufferDirect");
|
||||
throw new RuntimeException(" Missing test name: array, arrayOffset, buffer, bufferHeap, bufferDirect, arrayView");
|
||||
}
|
||||
|
||||
Test te;
|
||||
|
@ -175,6 +213,9 @@ public class TestBufferVectorization {
|
|||
case "bufferDirect":
|
||||
te = new TestBuffer(direct_buffer_byte_to_int);
|
||||
break;
|
||||
case "arrayView":
|
||||
te = new TestArrayView();
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException(" Unknown test: " + args[0]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue