1 /*
 2  * Copyright (c) 2021, Huawei Technologies Co., Ltd. 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.vectorapi;
25 
26 import jdk.incubator.vector.IntVector;
27 import jdk.incubator.vector.LongVector;
28 import jdk.incubator.vector.VectorSpecies;
29 
30 /*
31  * @test
32  * @bug 8260339
33  * @summary StoreVectorNode is not considered with -XX:+OptimizeFill
34  * @modules jdk.incubator.vector
35  *
36  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+OptimizeFill compiler.vectorapi.TestLoopStoreVector
37  */
38 
39 public class TestLoopStoreVector {
40     static final VectorSpecies<Integer> SPECIESi = IntVector.SPECIES_PREFERRED;
41     static final VectorSpecies<Long> SPECIESl = LongVector.SPECIES_PREFERRED;
42 
43     static final int INVOC_COUNT = 5000;
44     static final int size = 64;
45 
46     static int[] ai = {20, 21, 02, 14, 83, 119, 101, 101, 116, 121, 44, 32,
47                        73, 32, 76, 79, 86, 69, 32, 89, 79, 85, 32, 102, 111,
48                        114, 101, 118, 101, 114, 33, 32, 32, 32, 45, 45, 32,
49                        32, 32, 66, 121, 32, 87, 97, 110, 103, 72, 117, 97,
50                        110, 103,46, 76, 105, 102, 101, 32, 105, 115, 32, 116,
51                        104, 101, 32};
52     static long[] al = {102, 108, 111, 119, 101, 114, 32, 102, 111, 114, 32,
53                         119, 104, 105, 99, 104, 32, 108, 111, 118, 101, 32,
54                         105, 115, 32, 116, 104, 101, 32, 104, 111, 110, 101,
55                         121, 46, 32, 87, 101, 32, 119, 105, 108, 108, 32, 115,
56                         116, 105, 99, 107, 32, 116, 111, 103, 101, 116, 104,
57                         101, 114, 32, 33, 33, 33, 33, 32};
58 
59     public static void testVectorCastL2I(long[] input, int[] output, VectorSpecies<Long> speciesl, VectorSpecies<Integer> speciesi) {
60         LongVector av = LongVector.fromArray(speciesl, input, 0);
61         IntVector bv = (IntVector) av.castShape(speciesi, 0);
62         bv.intoArray(output, 0);
63     }
64 
65     public static int test0() {
66         for (int i = 0; i < 1000; i++) {
67             testVectorCastL2I(al, ai, SPECIESl, SPECIESi);
68         }
69         return 0;
70     }
71 
72     public static void main(String[] args) {
73         for (int i = 0; i < INVOC_COUNT; i++) {
74             test0();
75         }
76         for (int i = 0; i < 64; i++) {
77             System.out.print(ai[i] + " ");
78         }
79         System.out.println("");
80     }
81 }