Skip to content

Commit e14698d

Browse files
cosmo0920edsiper
authored andcommitted
simd: Define a fallback of flb_vector8_eq
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 40fff8e commit e14698d

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

include/fluent-bit/flb_simd.h

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,22 +215,34 @@ static inline flb_vector8 flb_vector8_ssub(const flb_vector8 v1, const flb_vecto
215215
/*
216216
* Return a vector with all bits set in each lane where the corresponding
217217
* lanes in the inputs are equal.
218+
* For CI or dockerized riscv64 environment, it doesn't have SIMD extension.
219+
* So, we need to define the fallback.
218220
*/
219-
#ifndef FLB_SIMD_NONE
220221
static inline flb_vector8 flb_vector8_eq(const flb_vector8 v1, const flb_vector8 v2)
221222
{
222-
#ifdef FLB_SIMD_SSE2
223-
return _mm_cmpeq_epi8(v1, v2);
223+
#if defined(FLB_SIMD_SSE2)
224+
return _mm_cmpeq_epi8(v1, v2);
224225
#elif defined(FLB_SIMD_NEON)
225-
return vceqq_u8(v1, v2);
226+
return vceqq_u8(v1, v2);
226227
#elif defined(FLB_SIMD_RVV)
227-
vbool8_t ret = __riscv_vmseq_vv_u8m1_b8(v1, v2, RVV_VEC8_INST_LEN);
228-
return __riscv_vmerge_vvm_u8m1(__riscv_vmv_v_x_u8m1(0, RVV_VEC8_INST_LEN),
229-
__riscv_vmv_v_x_u8m1(UINT8_MAX, RVV_VEC8_INST_LEN),
230-
ret, RVV_VEC8_INST_LEN);
228+
vbool8_t ret = __riscv_vmseq_vv_u8m1_b8(v1, v2, RVV_VEC8_INST_LEN);
229+
return __riscv_vmerge_vvm_u8m1(__riscv_vmv_v_x_u8m1(0, RVV_VEC8_INST_LEN),
230+
__riscv_vmv_v_x_u8m1(UINT8_MAX, RVV_VEC8_INST_LEN),
231+
ret, RVV_VEC8_INST_LEN);
232+
#else
233+
flb_vector8 result = 0;
234+
size_t i;
235+
const uint8_t *p1 = (const uint8_t *) &v1;
236+
const uint8_t *p2 = (const uint8_t *) &v2;
237+
uint8_t *out = (uint8_t *) &result;
238+
239+
for (i = 0; i < sizeof(flb_vector8); i++) {
240+
out[i] = (p1[i] == p2[i]) ? UINT8_MAX : 0;
241+
}
242+
243+
return result;
231244
#endif
232245
}
233-
#endif /* ! FLB_SIMD_NONE */
234246

235247
#ifndef FLB_SIMD_NONE
236248
static inline flb_vector32 flb_vector32_eq(const flb_vector32 v1, const flb_vector32 v2)

0 commit comments

Comments
 (0)