From: Michael R. Crusoe <crusoe@debian.org>
Subject: Add support for non-(amd64,Arm,PPC) using SIMD Everywhere
Forwarded: https://github.com/openmm/openmm/pull/4324
--- openmm.orig/openmmapi/include/openmm/internal/vectorize_sse.h
+++ openmm/openmmapi/include/openmm/internal/vectorize_sse.h
@@ -32,11 +32,8 @@
  * USE OR OTHER DEALINGS IN THE SOFTWARE.                                     *
  * -------------------------------------------------------------------------- */
 
-#ifdef __AVX__
-#include <immintrin.h>
-#else
-#include <smmintrin.h>
-#endif
+#define SIMDE_ENABLE_NATIVE_ALIASES
+#include <simde/x86/avx.h>
 
 #include "hardware.h"
 
@@ -101,7 +98,7 @@
     void storeVec3(float* v) const {
         // This code could be called from objects compiled for better SIMD domains (e.g., AVX) so conditionally
         // compile in the most efficient variant of the instruction.
-#ifdef  __AVX__
+#if defined(SIMDE_X86_AVX_NATIVE) || !defined(SIMDE_X86_SSE2_NATIVE)
         _mm_maskstore_ps(v, _mm_setr_epi32(-1, -1, -1, 0), val);
 #else
         _mm_maskmoveu_si128 (_mm_castps_si128(val), _mm_setr_epi32(-1, -1, -1, 0), (char*)v);
--- openmm.orig/openmmapi/include/openmm/internal/hardware.h
+++ openmm/openmmapi/include/openmm/internal/hardware.h
@@ -93,9 +93,8 @@
 #ifdef WIN32
 #define cpuid __cpuid
 #else
-#if !defined(__ANDROID__) && !defined(__PNACL__) && !defined(__PPC__) \
-    && !defined(__ARM__) && !defined(__ARM64__)
-    static void cpuid(int cpuInfo[4], int infoType) {
+#if defined(__x86_64__) || defined(__i386__)
+static void cpuid(int cpuInfo[4], int infoType) {
     #ifdef __LP64__
         __asm__ __volatile__ (
             "cpuid":
--- openmm.orig/libraries/vecmath/include/sse_mathfun.h
+++ openmm/libraries/vecmath/include/sse_mathfun.h
@@ -29,7 +29,8 @@
   (this is the zlib license)
 */
 
-#include <xmmintrin.h>
+#define SIMDE_ENABLE_NATIVE_ALIASES
+#include <simde/x86/sse.h>
 #include "openmm/internal/windowsExport.h"
 
 /* yes I know, the top of this file is quite ugly */
@@ -46,7 +47,7 @@
 typedef __m128 v4sf;  // vector of 4 float (sse1)
 
 #ifdef USE_SSE2
-# include <emmintrin.h>
+#include <simde/x86/sse2.h>
 typedef __m128i v4si; // vector of 4 int (sse2)
 #else
 typedef __m64 v2si;   // vector of 2 int (mmx)
--- openmm.orig/CMakeLists.txt
+++ openmm/CMakeLists.txt
@@ -89,9 +89,7 @@
 # The source is organized into subdirectories, but we handle them all from
 # this CMakeLists file rather than letting CMake visit them as SUBDIRS.
 SET(OPENMM_SOURCE_SUBDIRS . openmmapi olla libraries/jama libraries/quern libraries/lepton libraries/sfmt libraries/lbfgs libraries/hilbert libraries/csha1 libraries/pocketfft platforms/reference serialization libraries/irrxml)
-IF(X86 OR ARM)
-    SET(OPENMM_SOURCE_SUBDIRS ${OPENMM_SOURCE_SUBDIRS} libraries/vecmath)
-ENDIF()
+SET(OPENMM_SOURCE_SUBDIRS ${OPENMM_SOURCE_SUBDIRS} libraries/vecmath)
 IF(WIN32)
     SET(OPENMM_SOURCE_SUBDIRS ${OPENMM_SOURCE_SUBDIRS} libraries/pthreads)
 ELSE(WIN32)
