@@ -160,7 +160,7 @@ private static int reduceLanes(int init, int[] arr, int vlen, binOpInt f) {
160160 return result ;
161161 }
162162
163- private static long reduceLanes (long init , long [] arr , int vlen ,binOpLong f ) {
163+ private static long reduceLanes (long init , long [] arr , int vlen , binOpLong f ) {
164164 long result = init ;
165165 for (int i = 0 ; i < vlen ; i ++) {
166166 result = f .apply (arr [i ], result );
@@ -216,61 +216,30 @@ public long testAddReductionLong_256() {
216216 return result ;
217217 }
218218
219- private static void verifyAddReductionFloat (float actual , float [] arr , int vlen ) {
220- float expected = 0.0f ;
221- for (int i = 0 ; i < vlen ; i ++) {
222- expected += arr [i ];
223- }
224- // Floating point addition reduction ops may introduce rounding errors.
225- float ROUNDING_ERROR_FACTOR_ADD = 10.0f ;
226- float tolerance = Math .ulp (expected ) * ROUNDING_ERROR_FACTOR_ADD ;
227- if (Math .abs (expected - actual ) > tolerance ) {
228- throw new RuntimeException (
229- "assertEqualsWithTolerance" +
230- ": expected " + expected + " but was " + actual +
231- " (tolerance: " + tolerance + ", diff: " + Math .abs (expected - actual ) + ")"
232- );
233- }
234- }
235-
236- private static void verifyAddReductionDouble (double actual , double [] arr , int vlen ) {
237- double expected = 0.0 ;
238- for (int i = 0 ; i < vlen ; i ++) {
239- expected += arr [i ];
240- }
241- // Floating point addition reduction ops may introduce rounding errors.
242- double ROUNDING_ERROR_FACTOR_ADD = 10.0 ;
243- double tolerance = Math .ulp (expected ) * ROUNDING_ERROR_FACTOR_ADD ;
244- if (Math .abs (expected - actual ) > tolerance ) {
245- throw new RuntimeException (
246- "assertEqualsWithTolerance" +
247- ": expected " + expected + " but was " + actual +
248- " (tolerance: " + tolerance + ", diff: " + Math .abs (expected - actual ) + ")"
249- );
250- }
251- }
252-
219+ // Because the evaluation order of floating point reduction addition in the Vector
220+ // API is not guaranteed, it is difficult to choose a single tolerance that reliably
221+ // validates results for randomly generated floating‑point inputs. Given that there
222+ // are already extensive jtreg tests under "test/jdk/jdk/incubator/vector" that verify
223+ // the API’s numerical correctness, this test is instead focused solely on checking
224+ // the generated IRs, and deliberately does not assert on the computed result.
253225 @ Test
254226 @ IR (counts = {IRNode .VECTOR_MASK_GEN , "1" ,
255227 IRNode .ADD_REDUCTION_VF , "1" },
256228 applyIfCPUFeature = {"sve" , "true" }, applyIf = {"MaxVectorSize" , ">=32" })
257229 public float testAddReductionFloat () {
258230 FloatVector v = FloatVector .fromArray (FSPEC_128 , fa , 0 );
259- float result = v .reduceLanes (VectorOperators .ADD );
260- verifyAddReductionFloat (result , fa , FSPEC_128 .length ());
261- return result ;
231+ return v .reduceLanes (VectorOperators .ADD );
262232 }
263233
264-
234+ // Same with above test for float type, this test does not validate the numerical
235+ // result and focuses solely on checking the correctness of the generated IR.
265236 @ Test
266237 @ IR (counts = {IRNode .VECTOR_MASK_GEN , "1" ,
267238 IRNode .ADD_REDUCTION_VD , "1" },
268239 applyIfCPUFeature = {"sve" , "true" }, applyIf = {"MaxVectorSize" , ">=32" })
269240 public double testAddReductionDouble () {
270241 DoubleVector v = DoubleVector .fromArray (DSPEC_128 , da , 0 );
271- double result = v .reduceLanes (VectorOperators .ADD );
272- verifyAddReductionDouble (result , da , DSPEC_128 .length ());
273- return result ;
242+ return v .reduceLanes (VectorOperators .ADD );
274243 }
275244
276245 // ============== Reduction Tests - Logical ==============
0 commit comments