Skip to content

Commit f403eee

Browse files
committed
msvc arm64 neon: work around 2 miscompilation bugs
for 4 Bitwise Exclusive OR poly intrinsics: https://developercommunity.visualstudio.com/t/MSVC-ARM64-miscompiles-NEON-vadd-and-vad/11148617 One of the vqrshrnh_n_u16 intrinsic (Unsigned saturating Rounded Shift Right Narrow (immediate) https://developercommunity.visualstudio.com/t/Numerical-error-in-ARM-Neon-vqrshrnh_n_/11148967
1 parent 2bd68c7 commit f403eee

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

‎simde/arm/neon/add.h‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ simde_vaddq_u64(simde_uint64x2_t a, simde_uint64x2_t b) {
796796
SIMDE_FUNCTION_ATTRIBUTES
797797
simde_poly8x8_t
798798
simde_vadd_p8(simde_poly8x8_t a, simde_poly8x8_t b) {
799-
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) && !defined(_GCC_ARM_NEON_H)
799+
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) && !defined(_GCC_ARM_NEON_H) && !defined(SIMDE_BUG_MSVC_11148617)
800800
return vadd_p8(a, b);
801801
#else
802802
simde_poly8x8_private
@@ -813,15 +813,15 @@ simde_vadd_p8(simde_poly8x8_t a, simde_poly8x8_t b) {
813813
#endif
814814
}
815815
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) || (defined(SIMDE_ENABLE_NATIVE_ALIASES) && \
816-
defined(_GCC_ARM_NEON_H))
816+
(defined(_GCC_ARM_NEON_H) || defined(SIMDE_BUG_MSVC_11148617)))
817817
#undef vadd_p8
818818
#define vadd_p8(a, b) simde_vadd_p8((a), (b))
819819
#endif
820820

821821
SIMDE_FUNCTION_ATTRIBUTES
822822
simde_poly16x4_t
823823
simde_vadd_p16(simde_poly16x4_t a, simde_poly16x4_t b) {
824-
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) && !defined(_GCC_ARM_NEON_H)
824+
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) && !defined(_GCC_ARM_NEON_H) && !defined(SIMDE_BUG_MSVC_11148617)
825825
return vadd_p16(a, b);
826826
#else
827827
simde_poly16x4_private
@@ -838,7 +838,7 @@ simde_vadd_p16(simde_poly16x4_t a, simde_poly16x4_t b) {
838838
#endif
839839
}
840840
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) || (defined(SIMDE_ENABLE_NATIVE_ALIASES) && \
841-
defined(_GCC_ARM_NEON_H))
841+
(defined(_GCC_ARM_NEON_H) || defined(SIMDE_BUG_MSVC_11148617)))
842842
#undef vadd_p16
843843
#define vadd_p16(a, b) simde_vadd_p16((a), (b))
844844
#endif
@@ -873,7 +873,7 @@ simde_vadd_p64(simde_poly64x1_t a, simde_poly64x1_t b) {
873873
SIMDE_FUNCTION_ATTRIBUTES
874874
simde_poly8x16_t
875875
simde_vaddq_p8(simde_poly8x16_t a, simde_poly8x16_t b) {
876-
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) && !defined(_GCC_ARM_NEON_H)
876+
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) && !defined(_GCC_ARM_NEON_H) && !defined(SIMDE_BUG_MSVC_11148617)
877877
return vaddq_p8(a, b);
878878
#else
879879
simde_poly8x16_private
@@ -890,15 +890,15 @@ simde_vaddq_p8(simde_poly8x16_t a, simde_poly8x16_t b) {
890890
#endif
891891
}
892892
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) || (defined(SIMDE_ENABLE_NATIVE_ALIASES) && \
893-
defined(_GCC_ARM_NEON_H))
893+
(defined(_GCC_ARM_NEON_H) || defined(SIMDE_BUG_MSVC_11148617)))
894894
#undef vaddq_p8
895895
#define vaddq_p8(a, b) simde_vaddq_p8((a), (b))
896896
#endif
897897

898898
SIMDE_FUNCTION_ATTRIBUTES
899899
simde_poly16x8_t
900900
simde_vaddq_p16(simde_poly16x8_t a, simde_poly16x8_t b) {
901-
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) && !defined(_GCC_ARM_NEON_H)
901+
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) && !defined(_GCC_ARM_NEON_H) && !defined(SIMDE_BUG_MSVC_11148617)
902902
return vaddq_p16(a, b);
903903
#else
904904
simde_poly16x8_private
@@ -915,7 +915,7 @@ simde_vaddq_p16(simde_poly16x8_t a, simde_poly16x8_t b) {
915915
#endif
916916
}
917917
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) || (defined(SIMDE_ENABLE_NATIVE_ALIASES) && \
918-
defined(_GCC_ARM_NEON_H))
918+
(defined(_GCC_ARM_NEON_H) || defined(SIMDE_BUG_MSVC_11148617)))
919919
#undef vaddq_p16
920920
#define vaddq_p16(a, b) simde_vaddq_p16((a), (b))
921921
#endif

‎simde/arm/neon/qrshrn_n.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ SIMDE_BEGIN_DECLS_
4646
#define vqrshrnh_n_s16(a, n) simde_vqrshrnh_n_s16(a, n)
4747
#endif
4848

49-
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
49+
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && !defined(SIMDE_BUG_MSVC_11148967)
5050
#define simde_vqrshrnh_n_u16(a, n) vqrshrnh_n_u16(a, n)
5151
#else
5252
#define simde_vqrshrnh_n_u16(a, n) simde_vqmovnh_u16(simde_x_vrshrh_n_u16(a, n))
5353
#endif
54-
#if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
54+
#if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES) || (defined(SIMDE_ENABLE_NATIVE_ALIASES) && \
55+
defined(SIMDE_BUG_MSVC_11148967))
5556
#undef vqrshrnh_n_u16
5657
#define vqrshrnh_n_u16(a, n) simde_vqrshrnh_n_u16(a, n)
5758
#endif

‎simde/simde-common.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,11 @@ HEDLEY_DIAGNOSTIC_POP
11871187
# elif defined(HEDLEY_MSVC_VERSION)
11881188
# if defined(SIMDE_ARCH_X86)
11891189
# define SIMDE_BUG_MSVC_ROUND_EXTRACT
1190+
# elif defined(SIMDE_ARM_NEON_A32V7_NATIVE)
1191+
# define SIMDE_BUG_MSVC_11148617
1192+
# endif
1193+
# if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
1194+
# define SIMDE_BUG_MSVC_11148967
11901195
# endif
11911196
# elif defined(HEDLEY_INTEL_VERSION)
11921197
# define SIMDE_BUG_INTEL_857088

0 commit comments

Comments
 (0)