[vlc-commits] [Git][videolan/vlc][master] 2 commits: cpu: remove the old SSE register tests

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Fri Mar 3 20:57:09 UTC 2023



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
e076fbe7 by Rémi Denis-Courmont at 2023-03-03T19:38:24+00:00
cpu: remove the old SSE register tests

Since CAN_COMPILE_SSE is no longer defined, this has been silently
disabled. Besides:
- This was always compiled out on Windows and OS/2.
- This is no longer linked in on Linux since the more robust
  /proc/cpuinfo checks were introduced.
- This is not used on MacOS at least since X86-32 support was dropped.

The point of this test was to verify that the OS scheduler supports
the SSE register bank. According to the introduction commit 22 years
ago (2788bc6a4e38026492aa9fb1f2b3b01cad61207d), the problem affected
Linux 2.2.x, which is long since unsupported.

In the end, we still test the CPU feature support via CPUID. Remove
this test only implicitly assumes that the OS kernel is not broken.

For what it is worth, this "fixes" the use of _exit() inside library
code which was flagged by some linting tools.

- - - - -
527a08ec by Rémi Denis-Courmont at 2023-03-03T19:38:24+00:00
meson: remove unused CAN_COMPILE_SSE check

- - - - -


3 changed files:

- buildsystem/simd_checks/meson.build
- config.h.meson
- src/misc/cpu.c


Changes:

=====================================
buildsystem/simd_checks/meson.build
=====================================
@@ -20,16 +20,6 @@ have_sse2_intrinsics = cc.compiles('''
 ''', args: ['-msse2'], name: 'SSE2 intrinsics check')
 cdata.set('HAVE_SSE2_INTRINSICS', have_sse2_intrinsics)
 
-# Check for SSE inline assembly support
-can_compile_sse = cc.compiles('''
-    void f() {
-        void *p;
-        asm volatile("xorps %%xmm1,%%xmm2"::"r"(p):"xmm1", "xmm2");
-    }
-''', args: ['-msse'], name: 'SSE inline asm check')
-cdata.set('CAN_COMPILE_SSE', can_compile_sse)
-have_sse = can_compile_sse
-
 # Check for SSE2 inline assembly support
 can_compile_sse2 = cc.compiles('''
     void f() {


=====================================
config.h.meson
=====================================
@@ -100,9 +100,6 @@
 /* Define to 1 if SSE2 intrinsics are available. */
 #mesondefine HAVE_SSE2_INTRINSICS
 
-/* Define to 1 if SSE inline assembly is available. */
-#mesondefine CAN_COMPILE_SSE
-
 /* Define to 1 if SSE2 inline assembly is available. */
 #mesondefine CAN_COMPILE_SSE2
 


=====================================
src/misc/cpu.c
=====================================
@@ -39,21 +39,9 @@
 
 #include <assert.h>
 
-#include <sys/types.h>
-#ifndef _WIN32
-#include <unistd.h>
-#include <sys/wait.h>
-#include <signal.h>
-#else
-#include <errno.h>
 #if defined(_MSC_VER) && !defined(__clang__)
 # include <intrin.h> // __cpuid
 #endif
-#endif
-
-#ifdef __APPLE__
-#include <sys/sysctl.h>
-#endif
 
 #if defined(__OpenBSD__) && defined(__powerpc__)
 #include <sys/types.h>
@@ -61,46 +49,6 @@
 #include <machine/cpu.h>
 #endif
 
-#if defined (__i386__) || defined (__x86_64__)
-# if defined (HAVE_FORK)
-static bool vlc_CPU_check (const char *name, void (*func) (void))
-{
-    pid_t pid = fork();
-
-    switch (pid)
-    {
-        case 0:
-            signal (SIGILL, SIG_DFL);
-            func ();
-            _exit (0);
-        case -1:
-            return false;
-    }
-
-    int status;
-    while( waitpid( pid, &status, 0 ) == -1 );
-
-    if( WIFEXITED( status ) && WEXITSTATUS( status ) == 0 )
-        return true;
-
-    fprintf (stderr, "Warning: your CPU has %s instructions, but not your "
-                     "operating system.\n", name);
-    fprintf( stderr, "         some optimizations will be disabled unless "
-                     "you upgrade your OS\n" );
-    return false;
-}
-
-#if defined (CAN_COMPILE_SSE) && !defined (__SSE__)
-VLC_SSE static void SSE_test (void)
-{
-    asm volatile ("xorps %%xmm0,%%xmm0\n" : : : "xmm0", "xmm1");
-}
-#endif
-#else /* _WIN32 || __OS2__ */
-# define vlc_CPU_check(name, func) (1)
-#endif
-#endif
-
 /**
  * Determines the CPU capabilities.
  */
@@ -159,19 +107,14 @@ VLC_WEAK unsigned vlc_CPU_raw(void)
 
     cpuid( 0x00000001 );
 
-# if defined (CAN_COMPILE_SSE) && !defined (__SSE__)
-    if (( i_edx & 0x02000000 ) && vlc_CPU_check ("SSE", SSE_test))
-# endif
-    {
-        if (i_edx & 0x04000000)
-            i_capabilities |= VLC_CPU_SSE2;
-        if (i_ecx & 0x00000001)
-            i_capabilities |= VLC_CPU_SSE3;
-        if (i_ecx & 0x00000200)
-            i_capabilities |= VLC_CPU_SSSE3;
-        if (i_ecx & 0x00080000)
-            i_capabilities |= VLC_CPU_SSE4_1;
-    }
+    if (i_edx & 0x04000000)
+        i_capabilities |= VLC_CPU_SSE2;
+    if (i_ecx & 0x00000001)
+        i_capabilities |= VLC_CPU_SSE3;
+    if (i_ecx & 0x00000200)
+        i_capabilities |= VLC_CPU_SSSE3;
+    if (i_ecx & 0x00080000)
+        i_capabilities |= VLC_CPU_SSE4_1;
 
     /* test for additional capabilities */
     cpuid( 0x80000000 );



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c45fd72c96689d53187f8c06c6f2a8d3bea17b45...527a08ec49ff28beef6afa44a694001d698731d8

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c45fd72c96689d53187f8c06c6f2a8d3bea17b45...527a08ec49ff28beef6afa44a694001d698731d8
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list