|
| 1 | +/* |
| 2 | + * Copyright (c) 2022, Arm Limited. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. |
| 8 | + * |
| 9 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | + * accompanied this code). |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License version |
| 16 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | + * |
| 19 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | + * or visit www.oracle.com if you need additional information or have any |
| 21 | + * questions. |
| 22 | + */ |
| 23 | + |
| 24 | +package compiler.c2.irTests; |
| 25 | + |
| 26 | +import compiler.lib.ir_framework.*; |
| 27 | +import java.util.Random; |
| 28 | +import jdk.test.lib.Asserts; |
| 29 | +import jdk.test.lib.Utils; |
| 30 | + |
| 31 | +/* |
| 32 | + * @test |
| 33 | + * @bug 8283091 |
| 34 | + * @summary Auto-vectorization enhancement for type conversion between different data sizes. |
| 35 | + * @requires (os.simpleArch == "x64" & vm.cpu.features ~= ".*avx2.*") | os.arch=="aarch64" |
| 36 | + * @library /test/lib / |
| 37 | + * @run driver compiler.c2.irTests.TestVectorizeTypeConversion |
| 38 | + */ |
| 39 | + |
| 40 | +public class TestVectorizeTypeConversion { |
| 41 | + |
| 42 | + final private static int SIZE = 3000; |
| 43 | + |
| 44 | + private static double[] doublea = new double[SIZE]; |
| 45 | + private static double[] doubleb = new double[SIZE]; |
| 46 | + private static long[] longa = new long[SIZE]; |
| 47 | + private static long[] longb = new long[SIZE]; |
| 48 | + private static int[] inta = new int[SIZE]; |
| 49 | + private static int[] intb = new int[SIZE]; |
| 50 | + private static float[] floata = new float[SIZE]; |
| 51 | + private static float[] floatb = new float[SIZE]; |
| 52 | + |
| 53 | + public static void main(String[] args) { |
| 54 | + TestFramework.run(); |
| 55 | + } |
| 56 | + |
| 57 | + @Test |
| 58 | + @IR(counts = {IRNode.LOAD_VECTOR, ">0", |
| 59 | + IRNode.VECTOR_CAST_I2X, ">0", |
| 60 | + IRNode.STORE_VECTOR, ">0"}) |
| 61 | + private static void testConvI2D(double[] d, int[] a) { |
| 62 | + for(int i = 0; i < d.length; i++) { |
| 63 | + d[i] = (double) (a[i]); |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + @Test |
| 68 | + @IR(counts = {IRNode.LOAD_VECTOR, ">0", |
| 69 | + IRNode.VECTOR_CAST_I2X, ">0", |
| 70 | + IRNode.VECTOR_CAST_L2X, ">0", |
| 71 | + IRNode.STORE_VECTOR, ">0"}) |
| 72 | + private static void testConvI2L(int[] d1, int d2[], long[] a1, long[] a2) { |
| 73 | + for(int i = 0; i < d1.length; i++) { |
| 74 | + d1[i] = (int) (a1[i]); |
| 75 | + a2[i] = (long) (d2[i]); |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | + @Test |
| 80 | + @IR(counts = {IRNode.LOAD_VECTOR, ">0", |
| 81 | + IRNode.VECTOR_CAST_D2X, ">0", |
| 82 | + IRNode.VECTOR_CAST_F2X, ">0", |
| 83 | + IRNode.STORE_VECTOR, ">0"}) |
| 84 | + private static void testConvF2D(double[] d1, double[] d2, float[] a1, float[] a2) { |
| 85 | + for(int i = 0; i < d1.length; i++) { |
| 86 | + d1[i] = (double) (a1[i]); |
| 87 | + a2[i] = (float) (d2[i]); |
| 88 | + } |
| 89 | + } |
| 90 | + |
| 91 | + @Run(test = {"testConvI2D", "testConvI2L", "testConvF2D"}) |
| 92 | + private void test_runner() { |
| 93 | + testConvI2D(doublea, inta); |
| 94 | + testConvI2L(inta, intb, longa, longb); |
| 95 | + testConvF2D(doublea, doubleb, floata, floatb); |
| 96 | + } |
| 97 | +} |
0 commit comments