@img/sharp-libvips-dev-wasm32 1.3.0-rc.5 → 1.3.0-rc.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +23 -23
  2. package/include/expat.h +14 -2
  3. package/include/expat_config.h +6 -3
  4. package/include/expat_external.h +3 -2
  5. package/include/glib-2.0/glib/gvarianttype.h +16 -16
  6. package/include/glib-2.0/glib/gversionmacros.h +13 -0
  7. package/include/hwy/aligned_allocator.h +44 -2
  8. package/include/hwy/auto_tune.h +22 -6
  9. package/include/hwy/base.h +60 -90
  10. package/include/hwy/bit_set.h +410 -0
  11. package/include/hwy/cache_control.h +3 -2
  12. package/include/hwy/detect_compiler_arch.h +134 -14
  13. package/include/hwy/detect_targets.h +82 -36
  14. package/include/hwy/highway.h +15 -0
  15. package/include/hwy/nanobenchmark.h +12 -3
  16. package/include/hwy/ops/arm_neon-inl.h +96 -25
  17. package/include/hwy/ops/arm_sve-inl.h +250 -95
  18. package/include/hwy/ops/emu128-inl.h +12 -7
  19. package/include/hwy/ops/generic_ops-inl.h +271 -131
  20. package/include/hwy/ops/loongarch_lasx-inl.h +31 -9
  21. package/include/hwy/ops/loongarch_lsx-inl.h +33 -12
  22. package/include/hwy/ops/ppc_vsx-inl.h +99 -19
  23. package/include/hwy/ops/rvv-inl.h +239 -130
  24. package/include/hwy/ops/scalar-inl.h +22 -7
  25. package/include/hwy/ops/set_macros-inl.h +163 -107
  26. package/include/hwy/ops/wasm_128-inl.h +13 -22
  27. package/include/hwy/ops/x86_128-inl.h +223 -120
  28. package/include/hwy/ops/x86_256-inl.h +70 -134
  29. package/include/hwy/ops/x86_512-inl.h +130 -134
  30. package/include/hwy/print-inl.h +2 -0
  31. package/include/hwy/profiler.h +355 -264
  32. package/include/hwy/robust_statistics.h +3 -1
  33. package/include/hwy/timer.h +44 -0
  34. package/include/lcms2.h +34 -4
  35. package/include/libexif/exif-utils.h +1 -1
  36. package/include/libheif/heif_sequences.h +12 -2
  37. package/include/libheif/heif_uncompressed.h +8 -0
  38. package/include/libpng16/png.h +7 -7
  39. package/include/libpng16/pngconf.h +1 -1
  40. package/include/libpng16/pnglibconf.h +1 -1
  41. package/include/png.h +7 -7
  42. package/include/pngconf.h +1 -1
  43. package/include/pnglibconf.h +1 -1
  44. package/include/tiffconf.h +9 -10
  45. package/include/tiffio.h +10 -9
  46. package/include/tiffvers.h +1 -1
  47. package/include/ultrahdr_api.h +5 -11
  48. package/lib/glib-2.0/include/glibconfig.h +1 -1
  49. package/lib/libaom.a +0 -0
  50. package/lib/libcgif.a +0 -0
  51. package/lib/libexif.a +0 -0
  52. package/lib/libexif.la +1 -1
  53. package/lib/libexpat.a +0 -0
  54. package/lib/libexpat.la +3 -3
  55. package/lib/libffi.a +0 -0
  56. package/lib/libgio-2.0.a +0 -0
  57. package/lib/libglib-2.0.a +0 -0
  58. package/lib/libgmodule-2.0.a +0 -0
  59. package/lib/libgobject-2.0.a +0 -0
  60. package/lib/libgthread-2.0.a +0 -0
  61. package/lib/libheif.a +0 -0
  62. package/lib/libhwy.a +0 -0
  63. package/lib/libimagequant.a +0 -0
  64. package/lib/libjpeg.a +0 -0
  65. package/lib/liblcms2.a +0 -0
  66. package/lib/libpng.a +0 -0
  67. package/lib/libpng.la +2 -2
  68. package/lib/libpng16.a +0 -0
  69. package/lib/libpng16.la +2 -2
  70. package/lib/libresvg.a +0 -0
  71. package/lib/libsharpyuv.a +0 -0
  72. package/lib/libtiff.a +0 -0
  73. package/lib/libuhdr.a +0 -0
  74. package/lib/libvips-cpp.a +0 -0
  75. package/lib/libvips.a +0 -0
  76. package/lib/libwebp.a +0 -0
  77. package/lib/libwebpdecoder.a +0 -0
  78. package/lib/libwebpdemux.a +0 -0
  79. package/lib/libwebpmux.a +0 -0
  80. package/lib/libz.a +0 -0
  81. package/lib/pkgconfig/expat.pc +1 -1
  82. package/lib/pkgconfig/gio-2.0.pc +1 -1
  83. package/lib/pkgconfig/glib-2.0.pc +1 -1
  84. package/lib/pkgconfig/gmodule-2.0.pc +1 -1
  85. package/lib/pkgconfig/gmodule-export-2.0.pc +1 -1
  86. package/lib/pkgconfig/gmodule-no-export-2.0.pc +1 -1
  87. package/lib/pkgconfig/gobject-2.0.pc +1 -1
  88. package/lib/pkgconfig/gthread-2.0.pc +1 -1
  89. package/lib/pkgconfig/lcms2.pc +1 -1
  90. package/lib/pkgconfig/libexif.pc +1 -1
  91. package/lib/pkgconfig/libhwy.pc +3 -4
  92. package/lib/pkgconfig/libpng.pc +1 -1
  93. package/lib/pkgconfig/libpng16.pc +1 -1
  94. package/lib/pkgconfig/libsharpyuv.pc +1 -1
  95. package/lib/pkgconfig/libtiff-4.pc +2 -2
  96. package/lib/pkgconfig/libwebp.pc +1 -1
  97. package/lib/pkgconfig/libwebpdecoder.pc +11 -0
  98. package/lib/pkgconfig/libwebpmux.pc +1 -1
  99. package/package.json +1 -1
  100. package/versions.json +10 -10
  101. package/lib/libsharpyuv.la +0 -41
  102. package/lib/libtiff.la +0 -41
  103. package/lib/libwebp.la +0 -41
  104. package/lib/libwebpdemux.la +0 -41
  105. package/lib/libwebpmux.la +0 -41
@@ -1,4 +1,5 @@
1
1
  // Copyright 2021 Google LLC
2
+ // Copyright 2025 Arm Limited and/or its affiliates <open-source-office@arm.com>
2
3
  // SPDX-License-Identifier: Apache-2.0
3
4
  //
4
5
  // Licensed under the Apache License, Version 2.0 (the "License");
@@ -92,7 +93,7 @@
92
93
  #define HWY_SVE2 (1LL << 23)
93
94
  #define HWY_SVE (1LL << 24)
94
95
  // Bit 25 reserved for NEON
95
- #define HWY_NEON_BF16 (1LL << 26) // fp16/dot/bf16 (e.g. Neoverse V2/N2/N3)
96
+ #define HWY_NEON_BF16 (1LL << 26) // fp16/dot/bf16 (e.g. Neoverse V2/N2)
96
97
  // Bit 27 reserved for NEON
97
98
  #define HWY_NEON (1LL << 28) // Implies support for AES
98
99
  #define HWY_NEON_WITHOUT_AES (1LL << 29)
@@ -194,10 +195,21 @@
194
195
  #endif
195
196
  #endif // HWY_BROKEN_MSVC
196
197
 
198
+ #ifndef HWY_BROKEN_AVX10_2 // allow override
199
+ // AVX10_2 requires clang >= 20.1 (postpone to 23 due to "avx10.2-512" remnant,
200
+ // only removed in https://github.com/llvm/llvm-project/pull/157034) or
201
+ // gcc >= 15.2 with binutils 2.44.
202
+ #if (HWY_COMPILER_CLANG < 2300) && (HWY_COMPILER_GCC_ACTUAL < 1502)
203
+ #define HWY_BROKEN_AVX10_2 HWY_AVX10_2
204
+ #else
205
+ #define HWY_BROKEN_AVX10_2 0
206
+ #endif
207
+ #endif // HWY_BROKEN_AVX10_2
208
+
197
209
  #ifndef HWY_BROKEN_AVX3_DL_ZEN4 // allow override
198
- // AVX3_DL and AVX3_ZEN4 require clang >= 7 (ensured above), gcc >= 8.1 or ICC
210
+ // AVX3_DL and AVX3_ZEN4 require clang >= 7 (ensured above), gcc >= 10.1 or ICC
199
211
  // 2021.
200
- #if (HWY_COMPILER_GCC_ACTUAL && HWY_COMPILER_GCC_ACTUAL < 801) || \
212
+ #if (HWY_COMPILER_GCC_ACTUAL && HWY_COMPILER_GCC_ACTUAL < 1001) || \
201
213
  (HWY_COMPILER_ICC && HWY_COMPILER_ICC < 2021)
202
214
  #define HWY_BROKEN_AVX3_DL_ZEN4 (HWY_AVX3_DL | HWY_AVX3_ZEN4)
203
215
  #else
@@ -245,9 +257,10 @@
245
257
  #endif // HWY_BROKEN_ARM7_WITHOUT_VFP4
246
258
 
247
259
  #ifndef HWY_BROKEN_NEON_BF16 // allow override
248
- // HWY_NEON_BF16 requires recent compilers.
260
+ // Broken on older compilers:
249
261
  #if (HWY_COMPILER_CLANG != 0 && HWY_COMPILER_CLANG < 1700) || \
250
- (HWY_COMPILER_GCC_ACTUAL != 0 && HWY_COMPILER_GCC_ACTUAL < 1302)
262
+ (HWY_COMPILER_GCC_ACTUAL != 0 && HWY_COMPILER_GCC_ACTUAL < 1302) || \
263
+ (defined(__apple_build_version__) && __apple_build_version__ <= 17000000)
251
264
  #define HWY_BROKEN_NEON_BF16 (HWY_NEON_BF16)
252
265
  #else
253
266
  #define HWY_BROKEN_NEON_BF16 0
@@ -257,11 +270,11 @@
257
270
  // SVE[2] require recent clang or gcc versions.
258
271
 
259
272
  #ifndef HWY_BROKEN_SVE // allow override
260
- // GCC 10+. Clang 19 still has many test failures for SVE. No Apple CPU (at
261
- // least up to and including M4 and A18) has SVE.
262
- #if (HWY_COMPILER_CLANG && HWY_COMPILER_CLANG < 2000) || \
273
+ // Clang 22+, GCC 10+, except MSAN does not yet support SVE.
274
+ // No Apple CPU (at least up to and including M4 and A18) has SVE.
275
+ #if (HWY_COMPILER_CLANG && HWY_COMPILER_CLANG < 2200) || \
263
276
  (HWY_COMPILER_GCC_ACTUAL && HWY_COMPILER_GCC_ACTUAL < 1000) || \
264
- HWY_OS_APPLE
277
+ HWY_OS_APPLE || HWY_IS_MSAN
265
278
  #define HWY_BROKEN_SVE (HWY_SVE | HWY_SVE_256)
266
279
  #else
267
280
  #define HWY_BROKEN_SVE 0
@@ -269,16 +282,28 @@
269
282
  #endif // HWY_BROKEN_SVE
270
283
 
271
284
  #ifndef HWY_BROKEN_SVE2 // allow override
272
- // Clang 19 still has many test failures for SVE2.
273
- #if (HWY_COMPILER_CLANG && HWY_COMPILER_CLANG < 2000) || \
285
+ // Clang 22+, GCC 10+, except MSAN does not yet support SVE2.
286
+ // No Apple CPU (at least up to and including M4 and A18) has SVE2.
287
+ #if (HWY_COMPILER_CLANG && HWY_COMPILER_CLANG < 2200) || \
274
288
  (HWY_COMPILER_GCC_ACTUAL && HWY_COMPILER_GCC_ACTUAL < 1000) || \
275
- HWY_OS_APPLE
276
- #define HWY_BROKEN_SVE2 (HWY_SVE2 | HWY_SVE2_128)
289
+ HWY_OS_APPLE || HWY_IS_MSAN
290
+ #define HWY_BROKEN_SVE2 (HWY_SVE2)
277
291
  #else
278
292
  #define HWY_BROKEN_SVE2 0
279
293
  #endif
280
294
  #endif // HWY_BROKEN_SVE2
281
295
 
296
+ #ifndef HWY_BROKEN_SVE2_128 // allow override
297
+ // GCC 10+. Clang 21 works for SVE2_128, but not for SVE2 nor MSAN.
298
+ #if (HWY_COMPILER_CLANG && HWY_COMPILER_CLANG < 2100) || \
299
+ (HWY_COMPILER_GCC_ACTUAL && HWY_COMPILER_GCC_ACTUAL < 1000) || \
300
+ HWY_OS_APPLE || HWY_IS_MSAN
301
+ #define HWY_BROKEN_SVE2_128 (HWY_SVE2_128)
302
+ #else
303
+ #define HWY_BROKEN_SVE2_128 0
304
+ #endif
305
+ #endif // HWY_BROKEN_SVE2_128
306
+
282
307
  #ifndef HWY_BROKEN_PPC10 // allow override
283
308
  #if (HWY_COMPILER_GCC_ACTUAL && HWY_COMPILER_GCC_ACTUAL < 1100)
284
309
  // GCC 10 supports the -mcpu=power10 option but does not support the PPC10
@@ -332,9 +357,12 @@
332
357
  #ifndef HWY_BROKEN_LOONGARCH // allow override
333
358
  // Using __loongarch_sx and __loongarch_asx macros to
334
359
  // check whether LSX/LASX targets are available.
335
- #if !defined(__loongarch_sx)
360
+ // GCC does not work yet, see https://gcc.gnu.org/PR121875.
361
+ #if !defined(__loongarch_sx) && \
362
+ !(HWY_COMPILER_CLANG && HWY_COMPILER_CLANG >= 1800)
336
363
  #define HWY_BROKEN_LOONGARCH (HWY_LSX | HWY_LASX)
337
- #elif !defined(__loongarch_asx)
364
+ #elif !defined(__loongarch_asx) && \
365
+ !(HWY_COMPILER_CLANG && HWY_COMPILER_CLANG >= 1800)
338
366
  #define HWY_BROKEN_LOONGARCH (HWY_LASX)
339
367
  #else
340
368
  #define HWY_BROKEN_LOONGARCH 0
@@ -360,13 +388,13 @@
360
388
  // Allow the user to override this without any guarantee of success.
361
389
  #ifndef HWY_BROKEN_TARGETS
362
390
 
363
- #define HWY_BROKEN_TARGETS \
364
- (HWY_BROKEN_CLANG6 | HWY_BROKEN_32BIT | HWY_BROKEN_MSVC | \
365
- HWY_BROKEN_AVX3_DL_ZEN4 | HWY_BROKEN_AVX3_SPR | \
366
- HWY_BROKEN_ARM7_BIG_ENDIAN | HWY_BROKEN_ARM7_WITHOUT_VFP4 | \
367
- HWY_BROKEN_NEON_BF16 | HWY_BROKEN_SVE | HWY_BROKEN_SVE2 | \
368
- HWY_BROKEN_PPC10 | HWY_BROKEN_PPC_32BIT | HWY_BROKEN_RVV | \
369
- HWY_BROKEN_LOONGARCH | HWY_BROKEN_Z14)
391
+ #define HWY_BROKEN_TARGETS \
392
+ (HWY_BROKEN_CLANG6 | HWY_BROKEN_32BIT | HWY_BROKEN_MSVC | \
393
+ HWY_BROKEN_AVX10_2 | HWY_BROKEN_AVX3_DL_ZEN4 | HWY_BROKEN_AVX3_SPR | \
394
+ HWY_BROKEN_ARM7_BIG_ENDIAN | HWY_BROKEN_ARM7_WITHOUT_VFP4 | \
395
+ HWY_BROKEN_NEON_BF16 | HWY_BROKEN_SVE | HWY_BROKEN_SVE2 | \
396
+ HWY_BROKEN_SVE2_128 | HWY_BROKEN_PPC10 | HWY_BROKEN_PPC_32BIT | \
397
+ HWY_BROKEN_RVV | HWY_BROKEN_LOONGARCH | HWY_BROKEN_Z14)
370
398
 
371
399
  #endif // HWY_BROKEN_TARGETS
372
400
 
@@ -489,7 +517,8 @@
489
517
  #if defined(__ARM_FEATURE_AES) && \
490
518
  defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && \
491
519
  defined(__ARM_FEATURE_DOTPROD) && \
492
- defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC)
520
+ defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC) && \
521
+ defined(__ARM_FEATURE_MATMUL_INT8)
493
522
  #define HWY_BASELINE_NEON HWY_ALL_NEON
494
523
  #elif defined(__ARM_FEATURE_AES)
495
524
  #define HWY_BASELINE_NEON (HWY_NEON_WITHOUT_AES | HWY_NEON)
@@ -642,8 +671,7 @@
642
671
  #define HWY_BASELINE_AVX3_SPR 0
643
672
  #endif
644
673
 
645
- #if HWY_BASELINE_AVX3_SPR != 0 && defined(__AVX10_2__) && \
646
- (HWY_COMPILER_GCC_ACTUAL >= 1500 || HWY_COMPILER_CLANG >= 2001)
674
+ #if HWY_BASELINE_AVX3_SPR != 0 && defined(__AVX10_2__)
647
675
  #define HWY_BASELINE_AVX10_2 HWY_AVX10_2
648
676
  #else
649
677
  #define HWY_BASELINE_AVX10_2 0
@@ -669,7 +697,20 @@
669
697
  #define HWY_BASELINE_LOONGARCH 0
670
698
  #endif
671
699
 
672
- // Allow the user to override this without any guarantee of success.
700
+ // Workaround for libaom, which unconditionally defines HWY_BASELINE_TARGETS
701
+ // even when that would be disabled/broken. If so, at least use AVX2.
702
+ #if defined(HWY_BASELINE_TARGETS)
703
+ #if HWY_BASELINE_TARGETS == HWY_AVX3_DL && \
704
+ ((HWY_BROKEN_TARGETS | HWY_DISABLED_TARGETS) & HWY_AVX3_DL)
705
+ #undef HWY_BASELINE_TARGETS
706
+ #define HWY_BASELINE_TARGETS HWY_AVX2
707
+ #endif
708
+ #endif // HWY_BASELINE_TARGETS
709
+
710
+ // Allow the user to override this without any guarantee of success. If the
711
+ // compiler invocation considers that target to be broken/disabled, then
712
+ // `HWY_ENABLED_BASELINE` will be 0 and users will have to check for that and
713
+ // skip their code.
673
714
  #ifndef HWY_BASELINE_TARGETS
674
715
  #define HWY_BASELINE_TARGETS \
675
716
  (HWY_BASELINE_SCALAR | HWY_BASELINE_WASM | HWY_BASELINE_PPC8 | \
@@ -686,7 +727,11 @@
686
727
 
687
728
  #define HWY_ENABLED_BASELINE HWY_ENABLED(HWY_BASELINE_TARGETS)
688
729
  #if HWY_ENABLED_BASELINE == 0
689
- #error "At least one baseline target must be defined and enabled"
730
+ #pragma message \
731
+ "All baseline targets are disabled or considered broken." \
732
+ "This is typically due to very restrictive HWY_BASELINE_TARGETS, or " \
733
+ "too expansive HWY_BROKEN_TARGETS or HWY_DISABLED_TAREGTS. User code " \
734
+ "must also check for this and skip any usage of SIMD."
690
735
  #endif
691
736
 
692
737
  // Best baseline, used for static dispatch. This is the least-significant 1-bit
@@ -744,12 +789,10 @@
744
789
  #endif // HWY_HAVE_AUXV
745
790
 
746
791
  #ifndef HWY_HAVE_RUNTIME_DISPATCH_RVV // allow override
747
- // The riscv_vector.h in Clang 16-18 requires compiler flags, and 19 still has
748
- // some missing intrinsics, see
749
- // https://github.com/llvm/llvm-project/issues/56592. GCC 13.3 also has an
750
- // #error check, whereas 14.1 fails with "argument type 'vuint16m8_t' requires
751
- // the V ISA extension": https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115325.
752
- #if HWY_ARCH_RISCV && HWY_COMPILER_CLANG >= 1900 && 0
792
+ // Clang 19+ supports target attributes for RVV intrinsics (resolved in
793
+ // https://github.com/llvm/llvm-project/issues/56592 and
794
+ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115325).
795
+ #if HWY_ARCH_RISCV && HWY_COMPILER_CLANG >= 1900
753
796
  #define HWY_HAVE_RUNTIME_DISPATCH_RVV 1
754
797
  #else
755
798
  #define HWY_HAVE_RUNTIME_DISPATCH_RVV 0
@@ -766,8 +809,8 @@
766
809
  #endif // HWY_HAVE_RUNTIME_DISPATCH_APPLE
767
810
 
768
811
  #ifndef HWY_HAVE_RUNTIME_DISPATCH_LOONGARCH // allow override
769
- #if HWY_ARCH_LOONGARCH && HWY_HAVE_AUXV && (defined(__loongarch_sx) || \
770
- defined(__loongarch_asx))
812
+ #if HWY_ARCH_LOONGARCH && HWY_HAVE_AUXV && !defined(__loongarch_asx) && \
813
+ HWY_COMPILER_CLANG && HWY_COMPILER_CLANG >= 1800
771
814
  #define HWY_HAVE_RUNTIME_DISPATCH_LOONGARCH 1
772
815
  #else
773
816
  #define HWY_HAVE_RUNTIME_DISPATCH_LOONGARCH 0
@@ -786,6 +829,9 @@
786
829
  // Allow opting out, and without a guarantee of success, opting-in.
787
830
  #ifndef HWY_HAVE_RUNTIME_DISPATCH
788
831
  // Clang, GCC and MSVC allow OS-independent runtime dispatch on x86.
832
+ // Wasm does not, because browsers reject a binary containing any SIMD
833
+ // instructions when the browser does not support them. Typical practice there
834
+ // is to build two binaries, one with the -msimd128 flag.
789
835
  #if HWY_ARCH_X86 || HWY_HAVE_RUNTIME_DISPATCH_RVV || \
790
836
  HWY_HAVE_RUNTIME_DISPATCH_APPLE || HWY_HAVE_RUNTIME_DISPATCH_LOONGARCH || \
791
837
  HWY_HAVE_RUNTIME_DISPATCH_LINUX
@@ -930,7 +976,7 @@
930
976
  // HWY_ONCE and the multiple-inclusion mechanism rely on HWY_STATIC_TARGET being
931
977
  // one of the dynamic targets. This also implies HWY_TARGETS != 0 and
932
978
  // (HWY_TARGETS & HWY_ENABLED_BASELINE) != 0.
933
- #if (HWY_TARGETS & HWY_STATIC_TARGET) == 0
979
+ #if (HWY_TARGETS & HWY_STATIC_TARGET) == 0 && HWY_ENABLED_BASELINE != 0
934
980
  #error "Logic error: best baseline should be included in dynamic targets"
935
981
  #endif
936
982
 
@@ -677,6 +677,19 @@ struct AddExport {
677
677
  #define HWY_HIGHWAY_PER_TARGET
678
678
  #endif
679
679
 
680
+ // No SIMD target enabled, skip header inclusion.
681
+ #if HWY_ENABLED_BASELINE == 0
682
+
683
+ // We would expect that HWY_TARGET and HWY_STATIC_TARGET are now both 0.
684
+ #if HWY_TARGET != 0
685
+ #error "Why is HWY_TARGET not 0 when HWY_ENABLED_BASELINE == 0?"
686
+ #endif
687
+ #if HWY_STATIC_TARGET != 0
688
+ #error "Why is HWY_STATIC_TARGET not 0 when HWY_ENABLED_BASELINE == 0?"
689
+ #endif
690
+
691
+ #else
692
+
680
693
  // These define ops inside namespace hwy::HWY_NAMESPACE.
681
694
  #if HWY_TARGET == HWY_SSE2 || HWY_TARGET == HWY_SSSE3 || HWY_TARGET == HWY_SSE4
682
695
  #include "hwy/ops/x86_128-inl.h"
@@ -713,4 +726,6 @@ struct AddExport {
713
726
 
714
727
  #include "hwy/ops/generic_ops-inl.h"
715
728
 
729
+ #endif // HWY_ENABLED_BASELINE
730
+
716
731
  #endif // HWY_HIGHWAY_PER_TARGET
@@ -50,6 +50,7 @@
50
50
 
51
51
  #include "hwy/highway_export.h"
52
52
  #include "hwy/timer.h" // IWYU pragma: export
53
+ #include "hwy/base.h"
53
54
 
54
55
  namespace hwy {
55
56
 
@@ -114,6 +115,14 @@ struct Result {
114
115
  float variability;
115
116
  };
116
117
 
118
+ // Returns a Params struct with customized configuration for benchmarks.
119
+ // Specifically limits `max_evals` to prevent timeout in tests.
120
+ static inline Params DefaultBenchmarkParams() {
121
+ Params p;
122
+ p.max_evals = HWY_IS_DEBUG_BUILD ? 3 : 4;
123
+ return p;
124
+ }
125
+
117
126
  // Precisely measures the number of ticks elapsed when calling "func" with the
118
127
  // given inputs, shuffled to ensure realistic branch prediction hit rates.
119
128
  //
@@ -132,8 +141,8 @@ HWY_DLLEXPORT size_t Measure(Func func, const uint8_t* arg,
132
141
 
133
142
  // Calls operator() of the given closure (lambda function).
134
143
  template <class Closure>
135
- static FuncOutput CallClosure(const Closure* f, const FuncInput input) {
136
- return (*f)(input);
144
+ static FuncOutput CallClosure(const void* f, const FuncInput input) {
145
+ return (*reinterpret_cast<const Closure*>(f))(input);
137
146
  }
138
147
 
139
148
  // Same as Measure, except "closure" is typically a lambda function of
@@ -143,7 +152,7 @@ static inline size_t MeasureClosure(const Closure& closure,
143
152
  const FuncInput* inputs,
144
153
  const size_t num_inputs, Result* results,
145
154
  const Params& p = Params()) {
146
- return Measure(reinterpret_cast<Func>(&CallClosure<Closure>),
155
+ return Measure(static_cast<Func>(&CallClosure<Closure>),
147
156
  reinterpret_cast<const uint8_t*>(&closure), inputs, num_inputs,
148
157
  results, p);
149
158
  }
@@ -1,5 +1,5 @@
1
1
  // Copyright 2019 Google LLC
2
- // Copyright 2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
2
+ // Copyright 2024-2026 Arm Limited and/or its affiliates <open-source-office@arm.com>
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  // SPDX-License-Identifier: BSD-3-Clause
5
5
  //
@@ -2903,15 +2903,15 @@ HWY_API Vec128<T, N> And(const Vec128<T, N> a, const Vec128<T, N> b) {
2903
2903
  // ------------------------------ AndNot
2904
2904
 
2905
2905
  namespace detail {
2906
- // reversed_andnot returns a & ~b.
2907
- HWY_NEON_DEF_FUNCTION_INTS_UINTS(reversed_andnot, vbic, _, 2)
2906
+ // AndNotSwap returns a & ~b, whereas AndNot is defined as ~a & b.
2907
+ HWY_NEON_DEF_FUNCTION_INTS_UINTS(AndNotSwap, vbic, _, 2)
2908
2908
  } // namespace detail
2909
2909
 
2910
2910
  // Returns ~not_mask & mask.
2911
2911
  template <typename T, size_t N, HWY_IF_NOT_FLOAT(T)>
2912
2912
  HWY_API Vec128<T, N> AndNot(const Vec128<T, N> not_mask,
2913
2913
  const Vec128<T, N> mask) {
2914
- return detail::reversed_andnot(mask, not_mask);
2914
+ return detail::AndNotSwap(mask, not_mask);
2915
2915
  }
2916
2916
 
2917
2917
  // Uses the u32/64 defined above.
@@ -2921,7 +2921,7 @@ HWY_API Vec128<T, N> AndNot(const Vec128<T, N> not_mask,
2921
2921
  const DFromV<decltype(mask)> d;
2922
2922
  const RebindToUnsigned<decltype(d)> du;
2923
2923
  VFromD<decltype(du)> ret =
2924
- detail::reversed_andnot(BitCast(du, mask), BitCast(du, not_mask));
2924
+ detail::AndNotSwap(BitCast(du, mask), BitCast(du, not_mask));
2925
2925
  return BitCast(d, ret);
2926
2926
  }
2927
2927
 
@@ -2951,6 +2951,13 @@ HWY_API Vec128<T, N> Xor(const Vec128<T, N> a, const Vec128<T, N> b) {
2951
2951
 
2952
2952
  // ------------------------------ Xor3
2953
2953
  #if HWY_ARCH_ARM_A64 && defined(__ARM_FEATURE_SHA3)
2954
+
2955
+ #ifdef HWY_NATIVE_XOR3
2956
+ #undef HWY_NATIVE_XOR3
2957
+ #else
2958
+ #define HWY_NATIVE_XOR3
2959
+ #endif
2960
+
2954
2961
  HWY_NEON_DEF_FUNCTION_FULL_UI(Xor3, veor3, _, 3)
2955
2962
 
2956
2963
  // Half vectors are not natively supported. Two Xor are likely more efficient
@@ -2968,11 +2975,6 @@ HWY_API Vec128<T, N> Xor3(const Vec128<T, N> x1, const Vec128<T, N> x2,
2968
2975
  return BitCast(d, Xor3(BitCast(du, x1), BitCast(du, x2), BitCast(du, x3)));
2969
2976
  }
2970
2977
 
2971
- #else
2972
- template <typename T, size_t N>
2973
- HWY_API Vec128<T, N> Xor3(Vec128<T, N> x1, Vec128<T, N> x2, Vec128<T, N> x3) {
2974
- return Xor(x1, Xor(x2, x3));
2975
- }
2976
2978
  #endif
2977
2979
 
2978
2980
  // ------------------------------ Or3
@@ -2987,6 +2989,45 @@ HWY_API Vec128<T, N> OrAnd(Vec128<T, N> o, Vec128<T, N> a1, Vec128<T, N> a2) {
2987
2989
  return Or(o, And(a1, a2));
2988
2990
  }
2989
2991
 
2992
+ // ------------------------------ XorAndNot
2993
+ #if HWY_ARCH_ARM_A64 && defined(__ARM_FEATURE_SHA3)
2994
+
2995
+ #ifdef HWY_NATIVE_BCAX
2996
+ #undef HWY_NATIVE_BCAX
2997
+ #else
2998
+ #define HWY_NATIVE_BCAX
2999
+ #endif
3000
+
3001
+ namespace detail {
3002
+ HWY_NEON_DEF_FUNCTION_FULL_UI(XorAndNotSwap, vbcax, _, 3)
3003
+ } // namespace detail
3004
+
3005
+ // As with AndNot, swap the last two arguments because our "negated first"
3006
+ // convention mismatches the intrinsics, which have the negated arg last.
3007
+ template <class V, HWY_IF_V_SIZE_V(V, 16), HWY_IF_NOT_FLOAT_V(V)>
3008
+ HWY_API V XorAndNot(V x, V a1, V a2) {
3009
+ return detail::XorAndNotSwap(x, a2, a1);
3010
+ }
3011
+
3012
+ // Half vectors are not natively supported. Two ops are likely more efficient
3013
+ // than Combine to 128-bit.
3014
+ template <typename T, size_t N, HWY_IF_V_SIZE_LE(T, N, 8), HWY_IF_NOT_FLOAT(T)>
3015
+ HWY_API Vec128<T, N> XorAndNot(Vec128<T, N> x, Vec128<T, N> a1,
3016
+ Vec128<T, N> a2) {
3017
+ return Xor(x, AndNot(a1, a2));
3018
+ }
3019
+
3020
+ template <typename T, size_t N, HWY_IF_FLOAT(T)>
3021
+ HWY_API Vec128<T, N> XorAndNot(const Vec128<T, N> x, const Vec128<T, N> a1,
3022
+ const Vec128<T, N> a2) {
3023
+ const DFromV<decltype(x)> d;
3024
+ const RebindToUnsigned<decltype(d)> du;
3025
+ return BitCast(d,
3026
+ XorAndNot(BitCast(du, x), BitCast(du, a1), BitCast(du, a2)));
3027
+ }
3028
+
3029
+ #endif
3030
+
2990
3031
  // ------------------------------ Operator overloads (internal-only if float)
2991
3032
 
2992
3033
  template <typename T, size_t N>
@@ -7352,6 +7393,9 @@ static HWY_INLINE bfloat16x8_t BitCastToRawNeonBF16(bfloat16x8_t raw) {
7352
7393
  // The uint16x4_t or uint16x8_t vector neets to be bitcasted to a bfloat16x4_t
7353
7394
  // or a bfloat16x8_t vector for the vbfdot_f32 and vbfdotq_f32 intrinsics if
7354
7395
  // HWY_NEON_HAVE_F32_TO_BF16C && !HWY_NEON_HAVE_BFLOAT16 is true
7396
+
7397
+ // NOTE: vbfdot uses round to odd unless the additional FEAT_EBF16 feature is
7398
+ // available and enabled.
7355
7399
  static HWY_INLINE bfloat16x4_t BitCastToRawNeonBF16(uint16x4_t raw) {
7356
7400
  return vreinterpret_bf16_u16(raw);
7357
7401
  }
@@ -7417,6 +7461,12 @@ HWY_API VFromD<D> ReorderWidenMulAccumulate(
7417
7461
  detail::BitCastToRawNeonBF16(b.raw)));
7418
7462
  }
7419
7463
 
7464
+ template <size_t N>
7465
+ HWY_API Vec128<float, N> RearrangeToOddPlusEven(Vec128<float, N> sum0,
7466
+ Vec128<float, N>) {
7467
+ return sum0;
7468
+ }
7469
+
7420
7470
  #endif // HWY_NEON_HAVE_F32_TO_BF16C
7421
7471
 
7422
7472
  template <class D, HWY_IF_I32_D(D)>
@@ -7543,17 +7593,6 @@ HWY_NEON_DEF_PAIRWISE_OPS(Max, vpmax)
7543
7593
  #undef HWY_NEON_DEF_PAIRWISE_OP
7544
7594
  } // namespace detail
7545
7595
 
7546
- template <size_t N>
7547
- HWY_API Vec128<float, N> RearrangeToOddPlusEven(Vec128<float, N> sum0,
7548
- Vec128<float, N> sum1) {
7549
- #if HWY_NEON_HAVE_BFLOAT16
7550
- (void)sum1; // unused by bf16 ReorderWidenMulAccumulate
7551
- return sum0;
7552
- #else
7553
- return Add(sum0, sum1);
7554
- #endif
7555
- }
7556
-
7557
7596
  HWY_API Vec128<int32_t> RearrangeToOddPlusEven(Vec128<int32_t> sum0,
7558
7597
  Vec128<int32_t> sum1) {
7559
7598
  // vmlal_s16 multiplied the lower half into sum0 and upper into sum1.
@@ -7612,7 +7651,8 @@ HWY_API Vec32<uint32_t> RearrangeToOddPlusEven(Vec32<uint32_t> sum0,
7612
7651
 
7613
7652
  // ------------------------------ SumOfMulQuadAccumulate
7614
7653
 
7615
- #if HWY_TARGET == HWY_NEON_BF16
7654
+
7655
+ #if HWY_TARGET == HWY_NEON_BF16 || defined(__ARM_FEATURE_DOTPROD)
7616
7656
 
7617
7657
  #ifdef HWY_NATIVE_I8_I8_SUMOFMULQUADACCUMULATE
7618
7658
  #undef HWY_NATIVE_I8_I8_SUMOFMULQUADACCUMULATE
@@ -7656,18 +7696,38 @@ HWY_API VFromD<DU32> SumOfMulQuadAccumulate(
7656
7696
  return VFromD<DU32>(vdotq_u32(sum.raw, a.raw, b.raw));
7657
7697
  }
7658
7698
 
7699
+ #endif //__ARM_FEATURE_DOTPROD || HWY_TARGET == HWY_NEON_BF16
7700
+
7659
7701
  #ifdef HWY_NATIVE_U8_I8_SUMOFMULQUADACCUMULATE
7660
7702
  #undef HWY_NATIVE_U8_I8_SUMOFMULQUADACCUMULATE
7661
7703
  #else
7662
7704
  #define HWY_NATIVE_U8_I8_SUMOFMULQUADACCUMULATE
7663
7705
  #endif
7664
7706
 
7707
+ #if defined(__ARM_FEATURE_MATMUL_INT8) || \
7708
+ (HWY_TARGET == HWY_NEON_BF16 && HWY_OS_APPLE && HWY_ARCH_ARM_A64 && \
7709
+ HWY_HAVE_RUNTIME_DISPATCH)
7710
+
7711
+ template <class DI32, HWY_IF_I32_D(DI32), HWY_IF_V_SIZE_LE_D(DI32, 8)>
7712
+ HWY_API VFromD<DI32> SumOfMulQuadAccumulate(
7713
+ DI32 /*di32*/, VFromD<Repartition<uint8_t, DI32>> a_u,
7714
+ VFromD<Repartition<int8_t, DI32>> b_i, VFromD<DI32> sum) {
7715
+ return VFromD<DI32>(vusdot_s32(sum.raw, a_u.raw, b_i.raw));
7716
+ }
7717
+
7718
+ template <class DI32, HWY_IF_I32_D(DI32), HWY_IF_V_SIZE_D(DI32, 16)>
7719
+ HWY_API VFromD<DI32> SumOfMulQuadAccumulate(
7720
+ DI32 /*di32*/, VFromD<Repartition<uint8_t, DI32>> a_u,
7721
+ VFromD<Repartition<int8_t, DI32>> b_i, VFromD<DI32> sum) {
7722
+ return VFromD<DI32>(vusdotq_s32(sum.raw, a_u.raw, b_i.raw));
7723
+ }
7724
+
7725
+ #else
7726
+
7665
7727
  template <class DI32, HWY_IF_I32_D(DI32)>
7666
7728
  HWY_API VFromD<DI32> SumOfMulQuadAccumulate(
7667
7729
  DI32 di32, VFromD<Repartition<uint8_t, DI32>> a_u,
7668
7730
  VFromD<Repartition<int8_t, DI32>> b_i, VFromD<DI32> sum) {
7669
- // TODO: use vusdot[q]_s32 on NEON targets that require support for NEON I8MM
7670
-
7671
7731
  const RebindToUnsigned<decltype(di32)> du32;
7672
7732
  const Repartition<uint8_t, decltype(di32)> du8;
7673
7733
 
@@ -7680,7 +7740,7 @@ HWY_API VFromD<DI32> SumOfMulQuadAccumulate(
7680
7740
  return BitCast(di32, Sub(result_sum0, result_sum1));
7681
7741
  }
7682
7742
 
7683
- #endif // HWY_TARGET == HWY_NEON_BF16
7743
+ #endif // __ARM_FEATURE_MATMUL_INT8
7684
7744
 
7685
7745
  // ------------------------------ WidenMulPairwiseAdd
7686
7746
 
@@ -8099,6 +8159,17 @@ HWY_API V InterleaveOddBlocks(D, V a, V /*b*/) {
8099
8159
  return a;
8100
8160
  }
8101
8161
 
8162
+ // ------------------------------ InterleaveLowerBlocks
8163
+ template <class D, class V = VFromD<D>>
8164
+ HWY_API V InterleaveLowerBlocks(D, V a, V /*b*/) {
8165
+ return a;
8166
+ }
8167
+ // ------------------------------ InterleaveUpperBlocks
8168
+ template <class D, class V = VFromD<D>>
8169
+ HWY_API V InterleaveUpperBlocks(D, V a, V /*b*/) {
8170
+ return a;
8171
+ }
8172
+
8102
8173
  // ------------------------------ ReverseBlocks
8103
8174
  // Single block: no change
8104
8175
  template <class D, HWY_IF_V_SIZE_LE_D(D, 16)>