/*
 * Copyright LWJGL. All rights reserved.
 * License terms: http://lwjgl.org/license.php
 */
package org.lwjgl.system.simd;

import org.testng.annotations.Test;

import static java.lang.Math.*;
import static org.lwjgl.system.simd.SSE.*;
import static org.lwjgl.system.simd.SSE3.*;
import static org.testng.Assert.*;

@Test
public class SSETest {

	public void testControlRegister() {
		int flushZeroMode = _MM_GET_FLUSH_ZERO_MODE();
		int roundingMode = _MM_GET_ROUNDING_MODE();
		int denormalsZeroMode = _MM_GET_DENORMALS_ZERO_MODE();

		try {
			// Default behavior
			_MM_SET_EXCEPTION_STATE(0);
			assertEquals(_MM_GET_EXCEPTION_STATE(), 0);

			float f = Float.MIN_VALUE;
			assertEquals(_MM_GET_EXCEPTION_STATE() & _MM_EXCEPT_DENORM, 0);

			f *= nextAfter(1.0f, 0.0);
			assertEquals(_MM_GET_EXCEPTION_STATE() & _MM_EXCEPT_DENORM, _MM_EXCEPT_DENORM);
			assertEquals(f, Float.MIN_VALUE);

			// Denormals are zero mode
			_MM_SET_EXCEPTION_STATE(0);
			assertEquals(_MM_GET_EXCEPTION_STATE(), 0);

			_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
			_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);

			f *= nextAfter(1.0f, 0.0);
			assertEquals(_MM_GET_EXCEPTION_STATE() & _MM_EXCEPT_DENORM, 0);
			assertEquals(f, 0.0f);
		} finally {
			// Reset control register
			_MM_SET_DENORMALS_ZERO_MODE(denormalsZeroMode);
			_MM_SET_ROUNDING_MODE(roundingMode);
			_MM_SET_FLUSH_ZERO_MODE(flushZeroMode);
		}
	}

}
@@ -736,24 +736,65 @@
 ENORM, 0);%0A%0A
+%09%09%09for ( int i = 0; i %3C 100000; i++ ) %7B%0A%09
 %09%09%09f *= next
@@ -803,32 +803,38 @@
 ter(1.0f, 0.0);%0A
+%09%09%09%7D%0A%0A
 %09%09%09assertEquals(
@@ -1146,24 +1146,65 @@
 _ZERO_ON);%0A%0A
+%09%09%09for ( int i = 0; i %3C 100000; i++ ) %7B%0A%09
 %09%09%09f *= next
@@ -1217,24 +1217,30 @@
 1.0f, 0.0);%0A
+%09%09%09%7D%0A%0A
 %09%09%09assertEqu

Use a loop to make the client JVM use SSE