8284981: Support the vectorization of some counting-down loops in SLP
Reviewed-by: roland, kvn
This commit is contained in:
parent
e54f26aa3d
commit
df7fba1cda
src/hotspot/share/opto
test/hotspot/jtreg/compiler
@ -3997,7 +3997,7 @@ bool SWPointer::scaled_iv_plus_offset(Node* n) {
|
||||
NOT_PRODUCT(_tracer.scaled_iv_plus_offset_5(n);)
|
||||
return true;
|
||||
}
|
||||
} else if (opc == Op_SubI) {
|
||||
} else if (opc == Op_SubI || opc == Op_SubL) {
|
||||
if (offset_plus_k(n->in(2), true) && scaled_iv_plus_offset(n->in(1))) {
|
||||
NOT_PRODUCT(_tracer.scaled_iv_plus_offset_6(n);)
|
||||
return true;
|
||||
@ -4316,7 +4316,7 @@ void SWPointer::Tracer::scaled_iv_plus_offset_5(Node* n) {
|
||||
|
||||
void SWPointer::Tracer::scaled_iv_plus_offset_6(Node* n) {
|
||||
if(_slp->is_trace_alignment()) {
|
||||
print_depth(); tty->print_cr(" %d SWPointer::scaled_iv_plus_offset: Op_SubI PASSED", n->_idx);
|
||||
print_depth(); tty->print_cr(" %d SWPointer::scaled_iv_plus_offset: Op_%s PASSED", n->_idx, n->Name());
|
||||
print_depth(); tty->print(" \\ %d SWPointer::scaled_iv_plus_offset: in(1) is scaled_iv: ", n->in(1)->_idx); n->in(1)->dump();
|
||||
print_depth(); tty->print(" \\ %d SWPointer::scaled_iv_plus_offset: in(2) is offset_plus_k: ", n->in(2)->_idx); n->in(2)->dump();
|
||||
}
|
||||
@ -4324,7 +4324,7 @@ void SWPointer::Tracer::scaled_iv_plus_offset_6(Node* n) {
|
||||
|
||||
void SWPointer::Tracer::scaled_iv_plus_offset_7(Node* n) {
|
||||
if(_slp->is_trace_alignment()) {
|
||||
print_depth(); tty->print_cr(" %d SWPointer::scaled_iv_plus_offset: Op_SubI PASSED", n->_idx);
|
||||
print_depth(); tty->print_cr(" %d SWPointer::scaled_iv_plus_offset: Op_%s PASSED", n->_idx, n->Name());
|
||||
print_depth(); tty->print(" \\ %d SWPointer::scaled_iv_plus_offset: in(2) is scaled_iv: ", n->in(2)->_idx); n->in(2)->dump();
|
||||
print_depth(); tty->print(" \\ %d SWPointer::scaled_iv_plus_offset: in(1) is offset_plus_k: ", n->in(1)->_idx); n->in(1)->dump();
|
||||
}
|
||||
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package compiler.c2.irTests;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8284981
|
||||
* @summary Auto-vectorization enhancement for special counting down loops
|
||||
* @requires os.arch=="amd64" | os.arch=="x86_64" | os.arch=="aarch64"
|
||||
* @library /test/lib /
|
||||
* @run driver compiler.c2.irTests.TestAutoVecCountingDownLoop
|
||||
*/
|
||||
|
||||
public class TestAutoVecCountingDownLoop {
|
||||
final private static int ARRLEN = 3000;
|
||||
|
||||
private static int[] a = new int[ARRLEN];
|
||||
private static int[] b = new int[ARRLEN];
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestFramework.run();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@IR(counts = {IRNode.LOAD_VECTOR, " >0 "})
|
||||
@IR(counts = {IRNode.STORE_VECTOR, " >0 "})
|
||||
private static void testCountingDown(int[] a, int[] b) {
|
||||
for (int i = 2000; i > 0; i--) {
|
||||
b[ARRLEN - i] = a[ARRLEN - i];
|
||||
}
|
||||
}
|
||||
|
||||
@Run(test = "testCountingDown")
|
||||
private void testCountingDown_runner() {
|
||||
testCountingDown(a, b);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
@ -102,6 +102,7 @@ public class TestIntVect {
|
||||
test_andImm(a1, a2, a3);
|
||||
test_orImm(a1, a2);
|
||||
test_xorImm(a1, a2);
|
||||
test_cp_countingdown(a1, a2);
|
||||
}
|
||||
// Initialize
|
||||
for (int i=0; i<ARRLEN; i++) {
|
||||
@ -552,6 +553,10 @@ public class TestIntVect {
|
||||
for (int i=0; i<ARRLEN; i++) {
|
||||
errn += verify("test_xorImm: a2", i, a2[i], golden);
|
||||
}
|
||||
test_cp_countingdown(a1, a2);
|
||||
for (int i = 500; i > 0; i--) {
|
||||
errn += verify("test_cp_countingdown: a2", ARRLEN - i, a2[ARRLEN - i], a1[ARRLEN - i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -837,6 +842,12 @@ public class TestIntVect {
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_xorImm: " + (end - start));
|
||||
start = System.currentTimeMillis();
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
test_cp_countingdown(a1, a2);
|
||||
}
|
||||
end = System.currentTimeMillis();
|
||||
System.out.println("test_cp_countingdown: " + (end - start));
|
||||
|
||||
return errn;
|
||||
}
|
||||
@ -1095,7 +1106,11 @@ public class TestIntVect {
|
||||
b[i] = a[i] ^ 2032;
|
||||
}
|
||||
}
|
||||
|
||||
static void test_cp_countingdown(int[] a, int[] b) {
|
||||
for (int i = 500; i > 0; i--) {
|
||||
b[ARRLEN - i] = a[ARRLEN - i];
|
||||
}
|
||||
}
|
||||
|
||||
static int verify(String text, int i, int elem, int val) {
|
||||
if (elem != val) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user