< prev index next >

test/hotspot/jtreg/compiler/c2/cmove/TestScalarConditionalMoveCmpObj.java

Print this page

  1 /*
  2  * Copyright (c) 2025, Rivos Inc. 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  * @summary Test conditional move + compare object.
 34  * @library /test/lib /
 35  * @run driver ${test.main.class}
 36  */
 37 
 38 public class TestScalarConditionalMoveCmpObj {
 39     final private static int SIZE = 1024;
 40     private static final Random RANDOM = Utils.getRandomInstance();
 41 
 42     public static void main(String[] args) {
 43         TestFramework.runWithFlags("-XX:+UseCMoveUnconditionally", "-XX:-UseVectorCmov",
 44                                    "-XX:+UnlockExperimentalVMOptions", "-XX:-UseCompactObjectHeaders", "-XX:+UseCompressedOops");
 45         TestFramework.runWithFlags("-XX:+UseCMoveUnconditionally", "-XX:-UseVectorCmov",
 46                                    "-XX:+UnlockExperimentalVMOptions", "-XX:-UseCompactObjectHeaders", "-XX:-UseCompressedOops");
 47         TestFramework.runWithFlags("-XX:+UseCMoveUnconditionally", "-XX:-UseVectorCmov",
 48                                    "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCompactObjectHeaders", "-XX:+UseCompressedOops");
 49         TestFramework.runWithFlags("-XX:+UseCMoveUnconditionally", "-XX:-UseVectorCmov",
 50                                    "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCompactObjectHeaders", "-XX:-UseCompressedOops");
 51     }
 52 






 53     // Object comparison
 54     //    O for I
 55     private int cmoveOEQforI(Object a, Object b, int c, int d) {
 56         return (a == b) ? c : d;
 57     }
 58 
 59     private int cmoveONEforI(Object a, Object b, int c, int d) {
 60         return (a != b) ? c : d;
 61     }
 62 
 63     //    O for L
 64     private long cmoveOEQforL(Object a, Object b, long c, long d) {
 65         return (a == b) ? c : d;
 66     }
 67 
 68     private long cmoveONEforL(Object a, Object b, long c, long d) {
 69         return (a != b) ? c : d;
 70     }
 71 
 72     //    O for F

 78         return (a != b) ? c : d;
 79     }
 80 
 81     //    O for D
 82     private double cmoveOEQforD(Object a, Object b, double c, double d) {
 83         return (a == b) ? c : d;
 84     }
 85 
 86     private double cmoveONEforD(Object a, Object b, double c, double d) {
 87         return (a != b) ? c : d;
 88     }
 89 
 90     // Tests shows CMoveI is generated, so let @IR verify CMOVE_I.
 91     //
 92     @Test
 93     @IR(failOn = {IRNode.STORE_VECTOR})
 94     @IR(counts = {IRNode.CMOVE_I, ">0", IRNode.CMP_P, ">0"},
 95         applyIf = {"UseCompressedOops", "false"})
 96     @IR(counts = {IRNode.CMOVE_I, ">0", IRNode.CMP_N, ">0"},
 97         applyIf = {"UseCompressedOops", "true"})
 98     private static void testCMoveOEQforI(Object[] a, Object[] b, int[] c, int[] d, int[] r, int[] r2) {
 99         for (int i = 0; i < a.length; i++) {
100             int cc = c[i];
101             int dd = d[i];
102             r2[i] = cc + dd;
103             r[i] = (a[i] == b[i]) ? cc : dd;
104         }
105     }
106 
107     @Test
108     @IR(failOn = {IRNode.STORE_VECTOR})
109     @IR(counts = {IRNode.CMOVE_I, ">0", IRNode.CMP_P, ">0"},
110         applyIf = {"UseCompressedOops", "false"})
111     @IR(counts = {IRNode.CMOVE_I, ">0", IRNode.CMP_N, ">0"},
112         applyIf = {"UseCompressedOops", "true"})
113     private static void testCMoveONEforI(Object[] a, Object[] b, int[] c, int[] d, int[] r, int[] r2) {
114         for (int i = 0; i < a.length; i++) {
115             int cc = c[i];
116             int dd = d[i];
117             r2[i] = cc + dd;
118             r[i] = (a[i] != b[i]) ? cc : dd;
119         }
120     }
121 
122     // So far, CMoveL is not guaranteed to be generated, so @IR not verify CMOVE_L.
123     // TODO: enable CMOVE_L verification when it's guaranteed to generate CMOVE_L.
124     //
125     @Test
126     @IR(failOn = {IRNode.STORE_VECTOR})
127     // @IR(counts = {IRNode.CMOVE_L, ">0", IRNode.CMP_P, ">0"},
128     //     applyIf = {"UseCompressedOops", "false"})
129     // @IR(counts = {IRNode.CMOVE_L, ">0", IRNode.CMP_N, ">0"},
130     //     applyIf = {"UseCompressedOops", "true"})
131     private static void testCMoveOEQforL(Object[] a, Object[] b, long[] c, long[] d, long[] r, long[] r2) {
132         for (int i = 0; i < a.length; i++) {
133             long cc = c[i];
134             long dd = d[i];
135             r2[i] = cc + dd;
136             r[i] = (a[i] == b[i]) ? cc : dd;
137         }
138     }
139 
140     @Test
141     @IR(failOn = {IRNode.STORE_VECTOR})
142     // @IR(counts = {IRNode.CMOVE_L, ">0", IRNode.CMP_P, ">0"},
143     //     applyIf = {"UseCompressedOops", "false"})
144     // @IR(counts = {IRNode.CMOVE_L, ">0", IRNode.CMP_N, ">0"},
145     //     applyIf = {"UseCompressedOops", "true"})
146     private static void testCMoveONEforL(Object[] a, Object[] b, long[] c, long[] d, long[] r, long[] r2) {
147         for (int i = 0; i < a.length; i++) {
148             long cc = c[i];
149             long dd = d[i];
150             r2[i] = cc + dd;
151             r[i] = (a[i] != b[i]) ? cc : dd;
152         }
153     }
154 
155     @Test
156     @IR(failOn = {IRNode.STORE_VECTOR})
157     @IR(counts = {IRNode.CMOVE_F, ">0", IRNode.CMP_P, ">0"},
158         applyIf = {"UseCompressedOops", "false"})
159     @IR(counts = {IRNode.CMOVE_F, ">0", IRNode.CMP_N, ">0"},
160         applyIf = {"UseCompressedOops", "true"})
161     private static void testCMoveOEQforF(Object[] a, Object[] b, float[] c, float[] d, float[] r, float[] r2) {
162         for (int i = 0; i < a.length; i++) {
163             float cc = c[i];
164             float dd = d[i];
165             r2[i] = cc + dd;
166             r[i] = (a[i] == b[i]) ? cc : dd;
167         }
168     }
169 
170     @Test
171     @IR(failOn = {IRNode.STORE_VECTOR})
172     @IR(counts = {IRNode.CMOVE_F, ">0", IRNode.CMP_P, ">0"},
173         applyIf = {"UseCompressedOops", "false"})
174     @IR(counts = {IRNode.CMOVE_F, ">0", IRNode.CMP_N, ">0"},
175         applyIf = {"UseCompressedOops", "true"})
176     private static void testCMoveONEforF(Object[] a, Object[] b, float[] c, float[] d, float[] r, float[] r2) {
177         for (int i = 0; i < a.length; i++) {
178             float cc = c[i];
179             float dd = d[i];
180             r2[i] = cc + dd;
181             r[i] = (a[i] != b[i]) ? cc : dd;
182         }
183     }
184 
185     @Test
186     @IR(failOn = {IRNode.STORE_VECTOR})
187     @IR(counts = {IRNode.CMOVE_D, ">0", IRNode.CMP_P, ">0"},
188         applyIf = {"UseCompressedOops", "false"})
189     @IR(counts = {IRNode.CMOVE_D, ">0", IRNode.CMP_N, ">0"},
190         applyIf = {"UseCompressedOops", "true"})
191     private static void testCMoveOEQforD(Object[] a, Object[] b, double[] c, double[] d, double[] r, double[] r2) {
192         for (int i = 0; i < a.length; i++) {
193             double cc = c[i];
194             double dd = d[i];
195             r2[i] = cc + dd;
196             r[i] = (a[i] == b[i]) ? cc : dd;
197         }
198     }
199 
200     @Test
201     @IR(failOn = {IRNode.STORE_VECTOR})
202     @IR(counts = {IRNode.CMOVE_D, ">0", IRNode.CMP_P, ">0"},
203         applyIf = {"UseCompressedOops", "false"})
204     @IR(counts = {IRNode.CMOVE_D, ">0", IRNode.CMP_N, ">0"},
205         applyIf = {"UseCompressedOops", "true"})
206     private static void testCMoveONEforD(Object[] a, Object[] b, double[] c, double[] d, double[] r, double[] r2) {
207         for (int i = 0; i < a.length; i++) {
208             double cc = c[i];
209             double dd = d[i];
210             r2[i] = cc + dd;
211             r[i] = (a[i] != b[i]) ? cc : dd;
212         }
213     }
214 
215     @Warmup(0)
216     @Run(test = {// Object
217                  "testCMoveOEQforI",
218                  "testCMoveONEforI",
219                  "testCMoveOEQforL",
220                  "testCMoveONEforL",
221                  "testCMoveOEQforF",
222                  "testCMoveONEforF",
223                  "testCMoveOEQforD",
224                  "testCMoveONEforD",
225                 })
226     private void testCMove_runner_two() {
227         Object[] aO = new Object[SIZE];
228         Object[] bO = new Object[SIZE];
229         int[] cI = new int[SIZE];
230         int[] dI = new int[SIZE];
231         int[] rI = new int[SIZE];
232         long[] cL = new long[SIZE];
233         long[] dL = new long[SIZE];
234         long[] rL = new long[SIZE];
235         float[] cF = new float[SIZE];
236         float[] dF = new float[SIZE];
237         float[] rF = new float[SIZE];
238         double[] cD = new double[SIZE];
239         double[] dD = new double[SIZE];
240         double[] rD = new double[SIZE];
241 
242         init(aO);
243         shuffle(aO, bO);


244         init(cL);
245         init(dL);
246         init(cF);
247         init(dF);
248         init(cD);
249         init(dD);
250 
251         testCMoveOEQforI(aO, bO, cI, dI, rI, rI);
252         for (int i = 0; i < SIZE; i++) {
253             Asserts.assertEquals(rI[i], cmoveOEQforI(aO[i], bO[i], cI[i], dI[i]));
254         }
255 
256         testCMoveONEforI(aO, bO, cI, dI, rI, rI);
257         for (int i = 0; i < SIZE; i++) {
258             Asserts.assertEquals(rI[i], cmoveONEforI(aO[i], bO[i], cI[i], dI[i]));
259         }
260 
261         testCMoveOEQforL(aO, bO, cL, dL, rL, rL);
262         for (int i = 0; i < SIZE; i++) {
263             Asserts.assertEquals(rL[i], cmoveOEQforL(aO[i], bO[i], cL[i], dL[i]));

273             Asserts.assertEquals(rF[i], cmoveOEQforF(aO[i], bO[i], cF[i], dF[i]));
274         }
275 
276         testCMoveONEforF(aO, bO, cF, dF, rF, rF);
277         for (int i = 0; i < SIZE; i++) {
278             Asserts.assertEquals(rF[i], cmoveONEforF(aO[i], bO[i], cF[i], dF[i]));
279         }
280 
281         testCMoveOEQforD(aO, bO, cD, dD, rD, rD);
282         for (int i = 0; i < SIZE; i++) {
283             Asserts.assertEquals(rD[i], cmoveOEQforD(aO[i], bO[i], cD[i], dD[i]));
284         }
285 
286         testCMoveONEforD(aO, bO, cD, dD, rD, rD);
287         for (int i = 0; i < SIZE; i++) {
288             Asserts.assertEquals(rD[i], cmoveONEforD(aO[i], bO[i], cD[i], dD[i]));
289         }
290 
291     }
292 
293     private static void init(Object[] a) {
294         for (int i = 0; i < SIZE; i++) {
295             a[i] = new Object();
296         }
297     }
298 
299     private static void shuffle(Object[] a, Object[] b) {
300         for (int i = 0; i < a.length; i++) {
301             b[i] = a[i];
302         }
303         Random rand = new Random();
304         for (int i = 0; i < SIZE; i++) {
305             if (rand.nextInt(5) == 0) {
306                 Object t = b[i];
307                 b[i] = b[SIZE-1-i];
308                 b[SIZE-1-i] = t;
309             }
310         }
311     }
312 
313     private static void init(int[] a) {
314         for (int i = 0; i < SIZE; i++) {
315             a[i] = RANDOM.nextInt();
316         }
317     }
318 
319     private static void init(long[] a) {
320         for (int i = 0; i < SIZE; i++) {
321             a[i] = RANDOM.nextLong();
322         }
323     }
324 
325     private static void init(float[] a) {
326         for (int i = 0; i < SIZE; i++) {

  1 /*
  2  * Copyright (c) 2025, Rivos Inc. All rights reserved.
  3  * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
  4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5  *
  6  * This code is free software; you can redistribute it and/or modify it
  7  * under the terms of the GNU General Public License version 2 only, as
  8  * published by the Free Software Foundation.
  9  *
 10  * This code is distributed in the hope that it will be useful, but WITHOUT
 11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13  * version 2 for more details (a copy is included in the LICENSE file that
 14  * accompanied this code).
 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  */
 24 
 25 package compiler.c2.cmove;
 26 
 27 import compiler.lib.ir_framework.*;
 28 import java.util.Random;
 29 import jdk.test.lib.Asserts;
 30 import jdk.test.lib.Utils;
 31 
 32 /*
 33  * @test
 34  * @summary Test conditional move + compare object.
 35  * @library /test/lib /
 36  * @run driver ${test.main.class}
 37  */
 38 
 39 public class TestScalarConditionalMoveCmpObj {
 40     final private static int SIZE = 1024;
 41     private static final Random RANDOM = Utils.getRandomInstance();
 42 
 43     public static void main(String[] args) {
 44         TestFramework.runWithFlags("-XX:+UseCMoveUnconditionally", "-XX:-UseVectorCmov",
 45                                    "-XX:+UnlockExperimentalVMOptions", "-XX:-UseCompactObjectHeaders", "-XX:+UseCompressedOops");
 46         TestFramework.runWithFlags("-XX:+UseCMoveUnconditionally", "-XX:-UseVectorCmov",
 47                                    "-XX:+UnlockExperimentalVMOptions", "-XX:-UseCompactObjectHeaders", "-XX:-UseCompressedOops");
 48         TestFramework.runWithFlags("-XX:+UseCMoveUnconditionally", "-XX:-UseVectorCmov",
 49                                    "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCompactObjectHeaders", "-XX:+UseCompressedOops");
 50         TestFramework.runWithFlags("-XX:+UseCMoveUnconditionally", "-XX:-UseVectorCmov",
 51                                    "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCompactObjectHeaders", "-XX:-UseCompressedOops");
 52     }
 53 
 54     // While a value of type Object can be a value object, a value of type NotValue
 55     // cannot since it is a non-abstract non-value class and so cannot be the base
 56     // class of a value class. This makes sure that comparisons between values of
 57     // this type are simply pointer comparisons, and not substitutability
 58     static class NotValue {}
 59 
 60     // Object comparison
 61     //    O for I
 62     private int cmoveOEQforI(Object a, Object b, int c, int d) {
 63         return (a == b) ? c : d;
 64     }
 65 
 66     private int cmoveONEforI(Object a, Object b, int c, int d) {
 67         return (a != b) ? c : d;
 68     }
 69 
 70     //    O for L
 71     private long cmoveOEQforL(Object a, Object b, long c, long d) {
 72         return (a == b) ? c : d;
 73     }
 74 
 75     private long cmoveONEforL(Object a, Object b, long c, long d) {
 76         return (a != b) ? c : d;
 77     }
 78 
 79     //    O for F

 85         return (a != b) ? c : d;
 86     }
 87 
 88     //    O for D
 89     private double cmoveOEQforD(Object a, Object b, double c, double d) {
 90         return (a == b) ? c : d;
 91     }
 92 
 93     private double cmoveONEforD(Object a, Object b, double c, double d) {
 94         return (a != b) ? c : d;
 95     }
 96 
 97     // Tests shows CMoveI is generated, so let @IR verify CMOVE_I.
 98     //
 99     @Test
100     @IR(failOn = {IRNode.STORE_VECTOR})
101     @IR(counts = {IRNode.CMOVE_I, ">0", IRNode.CMP_P, ">0"},
102         applyIf = {"UseCompressedOops", "false"})
103     @IR(counts = {IRNode.CMOVE_I, ">0", IRNode.CMP_N, ">0"},
104         applyIf = {"UseCompressedOops", "true"})
105     private static void testCMoveOEQforI(NotValue[] a, NotValue[] b, int[] c, int[] d, int[] r, int[] r2) {
106         for (int i = 0; i < a.length; i++) {
107             int cc = c[i];
108             int dd = d[i];
109             r2[i] = cc + dd;
110             r[i] = (a[i] == b[i]) ? cc : dd;
111         }
112     }
113 
114     @Test
115     @IR(failOn = {IRNode.STORE_VECTOR})
116     @IR(counts = {IRNode.CMOVE_I, ">0", IRNode.CMP_P, ">0"},
117         applyIf = {"UseCompressedOops", "false"})
118     @IR(counts = {IRNode.CMOVE_I, ">0", IRNode.CMP_N, ">0"},
119         applyIf = {"UseCompressedOops", "true"})
120     private static void testCMoveONEforI(NotValue[] a, NotValue[] b, int[] c, int[] d, int[] r, int[] r2) {
121         for (int i = 0; i < a.length; i++) {
122             int cc = c[i];
123             int dd = d[i];
124             r2[i] = cc + dd;
125             r[i] = (a[i] != b[i]) ? cc : dd;
126         }
127     }
128 
129     // So far, CMoveL is not guaranteed to be generated, so @IR not verify CMOVE_L.
130     // TODO: enable CMOVE_L verification when it's guaranteed to generate CMOVE_L.
131     //
132     @Test
133     @IR(failOn = {IRNode.STORE_VECTOR})
134     // @IR(counts = {IRNode.CMOVE_L, ">0", IRNode.CMP_P, ">0"},
135     //     applyIf = {"UseCompressedOops", "false"})
136     // @IR(counts = {IRNode.CMOVE_L, ">0", IRNode.CMP_N, ">0"},
137     //     applyIf = {"UseCompressedOops", "true"})
138     private static void testCMoveOEQforL(NotValue[] a, NotValue[] b, long[] c, long[] d, long[] r, long[] r2) {
139         for (int i = 0; i < a.length; i++) {
140             long cc = c[i];
141             long dd = d[i];
142             r2[i] = cc + dd;
143             r[i] = (a[i] == b[i]) ? cc : dd;
144         }
145     }
146 
147     @Test
148     @IR(failOn = {IRNode.STORE_VECTOR})
149     // @IR(counts = {IRNode.CMOVE_L, ">0", IRNode.CMP_P, ">0"},
150     //     applyIf = {"UseCompressedOops", "false"})
151     // @IR(counts = {IRNode.CMOVE_L, ">0", IRNode.CMP_N, ">0"},
152     //     applyIf = {"UseCompressedOops", "true"})
153     private static void testCMoveONEforL(NotValue[] a, NotValue[] b, long[] c, long[] d, long[] r, long[] r2) {
154         for (int i = 0; i < a.length; i++) {
155             long cc = c[i];
156             long dd = d[i];
157             r2[i] = cc + dd;
158             r[i] = (a[i] != b[i]) ? cc : dd;
159         }
160     }
161 
162     @Test
163     @IR(failOn = {IRNode.STORE_VECTOR})
164     @IR(counts = {IRNode.CMOVE_F, ">0", IRNode.CMP_P, ">0"},
165         applyIf = {"UseCompressedOops", "false"})
166     @IR(counts = {IRNode.CMOVE_F, ">0", IRNode.CMP_N, ">0"},
167         applyIf = {"UseCompressedOops", "true"})
168     private static void testCMoveOEQforF(NotValue[] a, NotValue[] b, float[] c, float[] d, float[] r, float[] r2) {
169         for (int i = 0; i < a.length; i++) {
170             float cc = c[i];
171             float dd = d[i];
172             r2[i] = cc + dd;
173             r[i] = (a[i] == b[i]) ? cc : dd;
174         }
175     }
176 
177     @Test
178     @IR(failOn = {IRNode.STORE_VECTOR})
179     @IR(counts = {IRNode.CMOVE_F, ">0", IRNode.CMP_P, ">0"},
180         applyIf = {"UseCompressedOops", "false"})
181     @IR(counts = {IRNode.CMOVE_F, ">0", IRNode.CMP_N, ">0"},
182         applyIf = {"UseCompressedOops", "true"})
183     private static void testCMoveONEforF(NotValue[] a, NotValue[] b, float[] c, float[] d, float[] r, float[] r2) {
184         for (int i = 0; i < a.length; i++) {
185             float cc = c[i];
186             float dd = d[i];
187             r2[i] = cc + dd;
188             r[i] = (a[i] != b[i]) ? cc : dd;
189         }
190     }
191 
192     @Test
193     @IR(failOn = {IRNode.STORE_VECTOR})
194     @IR(counts = {IRNode.CMOVE_D, ">0", IRNode.CMP_P, ">0"},
195         applyIf = {"UseCompressedOops", "false"})
196     @IR(counts = {IRNode.CMOVE_D, ">0", IRNode.CMP_N, ">0"},
197         applyIf = {"UseCompressedOops", "true"})
198     private static void testCMoveOEQforD(NotValue[] a, NotValue[] b, double[] c, double[] d, double[] r, double[] r2) {
199         for (int i = 0; i < a.length; i++) {
200             double cc = c[i];
201             double dd = d[i];
202             r2[i] = cc + dd;
203             r[i] = (a[i] == b[i]) ? cc : dd;
204         }
205     }
206 
207     @Test
208     @IR(failOn = {IRNode.STORE_VECTOR})
209     @IR(counts = {IRNode.CMOVE_D, ">0", IRNode.CMP_P, ">0"},
210         applyIf = {"UseCompressedOops", "false"})
211     @IR(counts = {IRNode.CMOVE_D, ">0", IRNode.CMP_N, ">0"},
212         applyIf = {"UseCompressedOops", "true"})
213     private static void testCMoveONEforD(NotValue[] a, NotValue[] b, double[] c, double[] d, double[] r, double[] r2) {
214         for (int i = 0; i < a.length; i++) {
215             double cc = c[i];
216             double dd = d[i];
217             r2[i] = cc + dd;
218             r[i] = (a[i] != b[i]) ? cc : dd;
219         }
220     }
221 
222     @Warmup(0)
223     @Run(test = {// Object
224                  "testCMoveOEQforI",
225                  "testCMoveONEforI",
226                  "testCMoveOEQforL",
227                  "testCMoveONEforL",
228                  "testCMoveOEQforF",
229                  "testCMoveONEforF",
230                  "testCMoveOEQforD",
231                  "testCMoveONEforD",
232                 })
233     private void testCMove_runner_two() {
234         NotValue[] aO = new NotValue[SIZE];
235         NotValue[] bO = new NotValue[SIZE];
236         int[] cI = new int[SIZE];
237         int[] dI = new int[SIZE];
238         int[] rI = new int[SIZE];
239         long[] cL = new long[SIZE];
240         long[] dL = new long[SIZE];
241         long[] rL = new long[SIZE];
242         float[] cF = new float[SIZE];
243         float[] dF = new float[SIZE];
244         float[] rF = new float[SIZE];
245         double[] cD = new double[SIZE];
246         double[] dD = new double[SIZE];
247         double[] rD = new double[SIZE];
248 
249         init(aO);
250         shuffle(aO, bO);
251         init(cI);
252         init(dI);
253         init(cL);
254         init(dL);
255         init(cF);
256         init(dF);
257         init(cD);
258         init(dD);
259 
260         testCMoveOEQforI(aO, bO, cI, dI, rI, rI);
261         for (int i = 0; i < SIZE; i++) {
262             Asserts.assertEquals(rI[i], cmoveOEQforI(aO[i], bO[i], cI[i], dI[i]));
263         }
264 
265         testCMoveONEforI(aO, bO, cI, dI, rI, rI);
266         for (int i = 0; i < SIZE; i++) {
267             Asserts.assertEquals(rI[i], cmoveONEforI(aO[i], bO[i], cI[i], dI[i]));
268         }
269 
270         testCMoveOEQforL(aO, bO, cL, dL, rL, rL);
271         for (int i = 0; i < SIZE; i++) {
272             Asserts.assertEquals(rL[i], cmoveOEQforL(aO[i], bO[i], cL[i], dL[i]));

282             Asserts.assertEquals(rF[i], cmoveOEQforF(aO[i], bO[i], cF[i], dF[i]));
283         }
284 
285         testCMoveONEforF(aO, bO, cF, dF, rF, rF);
286         for (int i = 0; i < SIZE; i++) {
287             Asserts.assertEquals(rF[i], cmoveONEforF(aO[i], bO[i], cF[i], dF[i]));
288         }
289 
290         testCMoveOEQforD(aO, bO, cD, dD, rD, rD);
291         for (int i = 0; i < SIZE; i++) {
292             Asserts.assertEquals(rD[i], cmoveOEQforD(aO[i], bO[i], cD[i], dD[i]));
293         }
294 
295         testCMoveONEforD(aO, bO, cD, dD, rD, rD);
296         for (int i = 0; i < SIZE; i++) {
297             Asserts.assertEquals(rD[i], cmoveONEforD(aO[i], bO[i], cD[i], dD[i]));
298         }
299 
300     }
301 
302     private static void init(NotValue[] a) {
303         for (int i = 0; i < SIZE; i++) {
304             a[i] = new NotValue();
305         }
306     }
307 
308     private static void shuffle(NotValue[] a, NotValue[] b) {
309         for (int i = 0; i < a.length; i++) {
310             b[i] = a[i];
311         }
312         Random rand = new Random();
313         for (int i = 0; i < SIZE; i++) {
314             if (rand.nextInt(5) == 0) {
315                 NotValue t = b[i];
316                 b[i] = b[SIZE-1-i];
317                 b[SIZE-1-i] = t;
318             }
319         }
320     }
321 
322     private static void init(int[] a) {
323         for (int i = 0; i < SIZE; i++) {
324             a[i] = RANDOM.nextInt();
325         }
326     }
327 
328     private static void init(long[] a) {
329         for (int i = 0; i < SIZE; i++) {
330             a[i] = RANDOM.nextLong();
331         }
332     }
333 
334     private static void init(float[] a) {
335         for (int i = 0; i < SIZE; i++) {
< prev index next >