File tree Expand file tree Collapse file tree 3 files changed +18
-11
lines changed Expand file tree Collapse file tree 3 files changed +18
-11
lines changed Original file line number Diff line number Diff line change 87
87
simd_arg_converter, &arg1, \
88
88
simd_arg_converter, &arg2 \
89
89
)) return NULL ; \
90
- simd_data data; \
90
+ simd_data data = {. u64 = 0 }; \
91
91
data.RET = NPY_CAT (SIMD__IMPL_COUNT_, CONST_RNG)( \
92
92
SIMD__REPEAT_2IMM, NAME, IN0 \
93
- ) npyv_## NAME (arg1. data .IN0 , 0 ); \
93
+ ) data.RET ; \
94
94
simd_arg_free (&arg1); \
95
95
simd_arg ret = { \
96
96
.data = data, .dtype = simd_data_##RET \
Original file line number Diff line number Diff line change 34
34
#define npyv_shr_s64 (A , C ) vshlq_s64(A, npyv_setall_s64(-(C)))
35
35
36
36
// right by an immediate constant
37
- #define npyv_shri_u16 ( VEC , C ) ((C) == 0 ? VEC : vshrq_n_u16(VEC, C))
38
- #define npyv_shri_s16 ( VEC , C ) ((C) == 0 ? VEC : vshrq_n_s16(VEC, C))
39
- #define npyv_shri_u32 ( VEC , C ) ((C) == 0 ? VEC : vshrq_n_u32(VEC, C))
40
- #define npyv_shri_s32 ( VEC , C ) ((C) == 0 ? VEC : vshrq_n_s32(VEC, C))
41
- #define npyv_shri_u64 ( VEC , C ) ((C) == 0 ? VEC : vshrq_n_u64(VEC, C))
42
- #define npyv_shri_s64 ( VEC , C ) ((C) == 0 ? VEC : vshrq_n_s64(VEC, C))
37
+ #define npyv_shri_u16 vshrq_n_u16
38
+ #define npyv_shri_s16 vshrq_n_s16
39
+ #define npyv_shri_u32 vshrq_n_u32
40
+ #define npyv_shri_s32 vshrq_n_s32
41
+ #define npyv_shri_u64 vshrq_n_u64
42
+ #define npyv_shri_s64 vshrq_n_s64
43
43
44
44
/***************************
45
45
* Logical
Original file line number Diff line number Diff line change @@ -173,14 +173,21 @@ def test_operators_shift(self):
173
173
# left shift
174
174
shl = self .shl (vdata_a , count )
175
175
assert shl == data_shl_a
176
- # left shift by an immediate constant
177
- shli = self .shli (vdata_a , count )
178
- assert shli == data_shl_a
179
176
# load to cast
180
177
data_shr_a = self .load ([a >> count for a in data_a ])
181
178
# right shift
182
179
shr = self .shr (vdata_a , count )
183
180
assert shr == data_shr_a
181
+
182
+ # shift by zero or max or out-range immediate constant is not applicable and illogical
183
+ for count in range (1 , self ._scalar_size ()):
184
+ # load to cast
185
+ data_shl_a = self .load ([a << count for a in data_a ])
186
+ # left shift by an immediate constant
187
+ shli = self .shli (vdata_a , count )
188
+ assert shli == data_shl_a
189
+ # load to cast
190
+ data_shr_a = self .load ([a >> count for a in data_a ])
184
191
# right shift by an immediate constant
185
192
shri = self .shri (vdata_a , count )
186
193
assert shri == data_shr_a
You can’t perform that action at this time.
0 commit comments