Skip to content

Commit 2211e30

Browse files
committed
Refactor simd/conf.rb - balance
Align code for arm and x86_64 in parallel.
1 parent 58dc0aa commit 2211e30

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

ext/json/ext/simd/conf.rb

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
if RbConfig::CONFIG['host_cpu'] =~ /^(arm.*|aarch64.*)/
1+
case RbConfig::CONFIG['host_cpu']
2+
when /^(arm|aarch64)/
23
# Try to compile a small program using NEON instructions
34
if have_header('arm_neon.h')
45
have_type('uint8x16_t', headers=['arm_neon.h']) && try_compile(<<~'SRC')
@@ -8,20 +9,20 @@
89
if (argc > 100000) printf("%p", &test);
910
return 0;
1011
}
11-
SRC
12-
$defs.push("-DJSON_ENABLE_SIMD")
12+
SRC
13+
$defs.push("-DJSON_ENABLE_SIMD")
1314
end
14-
end
15-
16-
if have_header('x86intrin.h') && have_type('__m128i', headers=['x86intrin.h']) && try_compile(<<~'SRC')
17-
#include <x86intrin.h>
18-
int main(int argc, char **argv) {
19-
__m128i test = _mm_set1_epi8(32);
20-
if (argc > 100000) printf("%p", &test);
21-
return 0;
22-
}
23-
SRC
15+
when /^(x86_64|x64)/
16+
if have_header('x86intrin.h') && have_type('__m128i', headers=['x86intrin.h']) && try_compile(<<~'SRC')
17+
#include <x86intrin.h>
18+
int main(int argc, char **argv) {
19+
__m128i test = _mm_set1_epi8(32);
20+
if (argc > 100000) printf("%p", &test);
21+
return 0;
22+
}
23+
SRC
2424
$defs.push("-DJSON_ENABLE_SIMD")
25+
end
2526
end
2627

2728
have_header('cpuid.h')

0 commit comments

Comments
 (0)