jdk

Форк
0
/
TestAutoVecIntMinMax.java 
114 строк · 3.8 Кб
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.Utils;
29

30
/*
31
 * @test
32
 * @bug 8288107
33
 * @summary Auto-vectorization enhancement for integer Math.max/Math.min operations
34
 * @library /test/lib /
35
 * @requires vm.compiler2.enabled
36
 * @requires (os.simpleArch == "x64" & (vm.opt.UseSSE == "null" | vm.opt.UseSSE > 3))
37
 *           | os.arch == "aarch64" | (os.arch == "riscv64" & vm.opt.UseRVV == true)
38
 * @run driver compiler.c2.irTests.TestAutoVecIntMinMax
39
 */
40

41
public class TestAutoVecIntMinMax {
42
    private final static int LENGTH = 2000;
43
    private final static Random RANDOM = Utils.getRandomInstance();
44

45
    private static int[] a;
46
    private static int[] b;
47
    private static int[] c;
48

49
    static {
50
        a = new int[LENGTH];
51
        b = new int[LENGTH];
52
        c = new int[LENGTH];
53
        for(int i = 0; i < LENGTH; i++) {
54
            a[i] = RANDOM.nextInt();
55
            b[i] = RANDOM.nextInt();
56
        }
57
    }
58

59
    public static void main(String[] args) {
60
        TestFramework.run();
61
    }
62

63
    // Test for auto-vectorization of Math.min operation on an array of integers
64
    @Test
65
    @IR(counts = {IRNode.LOAD_VECTOR_I,  " >0 "})
66
    @IR(counts = {IRNode.MIN_VI, " >0 "})
67
    @IR(counts = {IRNode.STORE_VECTOR, " >0 "})
68
    private static void testIntMin(int[] a, int[] b) {
69
        for(int i = 0; i < LENGTH; i++) {
70
            c[i] = Math.min(a[i], b[i]);
71
        }
72
    }
73

74
    // Test for auto-vectorization of StrictMath.min operation on an array of integers
75
    @Test
76
    @IR(counts = {IRNode.LOAD_VECTOR_I,  " >0 "})
77
    @IR(counts = {IRNode.MIN_VI, " >0 "})
78
    @IR(counts = {IRNode.STORE_VECTOR, " >0 "})
79
    private static void testIntStrictMin(int[] a, int[] b) {
80
        for(int i = 0; i < LENGTH; i++) {
81
            c[i] = StrictMath.min(a[i], b[i]);
82
        }
83
    }
84

85
    // Test for auto-vectorization of Math.max operation on an array of integers
86
    @Test
87
    @IR(counts = {IRNode.LOAD_VECTOR_I,  " >0 "})
88
    @IR(counts = {IRNode.MAX_VI, " >0 "})
89
    @IR(counts = {IRNode.STORE_VECTOR, " >0 "})
90
    private static void testIntMax(int[] a, int[] b) {
91
        for(int i = 0; i < LENGTH; i++) {
92
            c[i] = Math.max(a[i], b[i]);
93
        }
94
    }
95

96
    // Test for auto-vectorization of StrictMath.max operation on an array of integers
97
    @Test
98
    @IR(counts = {IRNode.LOAD_VECTOR_I,  " >0 "})
99
    @IR(counts = {IRNode.MAX_VI, " >0 "})
100
    @IR(counts = {IRNode.STORE_VECTOR, " >0 "})
101
    private static void testIntStrictMax(int[] a, int[] b) {
102
        for(int i = 0; i < LENGTH; i++) {
103
            c[i] = StrictMath.max(a[i], b[i]);
104
        }
105
    }
106

107
    @Run(test = {"testIntMin", "testIntStrictMin", "testIntMax", "testIntStrictMax"})
108
    private void testIntMinMax_runner() {
109
        testIntMin(a, b);
110
        testIntStrictMin(a, b);
111
        testIntMax(a, b);
112
        testIntStrictMax(a, b);
113
    }
114
}
115

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.