Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions ext/json/ext/simd/conf.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
case RbConfig::CONFIG['host_cpu']
when /^(arm|aarch64)/
# Try to compile a small program using NEON instructions
header, type, init, extra = 'arm_neon.h', 'uint8x16_t', 'vdupq_n_u8(32)', nil
header, type, init = 'arm_neon.h', 'uint8x16_t', 'vdupq_n_u8(32)'
when /^(x86_64|x64)/
header, type, init, extra = 'x86intrin.h', '__m128i', '_mm_set1_epi8(32)', 'if (__builtin_cpu_supports("sse2")) { printf("OK"); }'
header, type, init = 'x86intrin.h', '__m128i', '_mm_set1_epi8(32)'
end
if header
if have_header(header) && try_compile(<<~SRC, '-Werror=implicit-function-declaration')
#{cpp_include(header)}
int main(int argc, char **argv) {
#{type} test = #{init};
#{extra}
if (argc > 100000) printf("%p", &test);
return 0;
}
Expand All @@ -20,5 +19,3 @@
puts "Disable SIMD"
end
end

have_header('cpuid.h')
12 changes: 2 additions & 10 deletions ext/json/ext/simd/simd.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ ALWAYS_INLINE(static) int string_scan_simd_neon(const char **ptr, const char *en
#define HAVE_SIMD 1
#define HAVE_SIMD_SSE2 1

#ifdef HAVE_CPUID_H
#define FIND_SIMD_IMPLEMENTATION_DEFINED 1

#if defined(__clang__) || defined(__GNUC__)
Expand Down Expand Up @@ -182,17 +181,10 @@ ALWAYS_INLINE(static) TARGET_SSE2 int string_scan_simd_sse2(const char **ptr, co
return 0;
}

#include <cpuid.h>
#endif /* HAVE_CPUID_H */

static inline SIMD_Implementation find_simd_implementation(void)
{
// TODO Revisit. I think the SSE version now only uses SSE2 instructions.
if (__builtin_cpu_supports("sse2")) {
return SIMD_SSE2;
}

return SIMD_NONE;
// SSE2 is part of the x86-64 baseline.
return SIMD_SSE2;
}

#endif /* HAVE_X86INTRIN_H */
Expand Down
Loading