Arm 在使用诸如NADEDS8的氖本质时,我们应该考虑溢出吗?

Arm 在使用诸如NADEDS8的氖本质时,我们应该考虑溢出吗?,arm,neon,Arm,Neon,如果我们有这样的C代码 spatial_pred= (cur[mrefs] + cur[prefs])>>1; 当转换为霓虹灯本质时 int8x8_t cur_mrefs = vld1_s8(cur+mrefs); int8x8_t cur_prefs = vld1_s8(cur+prefs); int8x8_t spatial_pred = vshr_n_s8(vadd_s8(cur_mrefs, cur_prefs), 1); 当VADHESS8(CurMeReS,CurrP

如果我们有这样的C代码

spatial_pred= (cur[mrefs] + cur[prefs])>>1;
当转换为霓虹灯本质时

int8x8_t cur_mrefs = vld1_s8(cur+mrefs);
int8x8_t cur_prefs = vld1_s8(cur+prefs);
int8x8_t spatial_pred = vshr_n_s8(vadd_s8(cur_mrefs, cur_prefs), 1);

当VADHESS8(CurMeReS,CurrPrIFS)时,我们需要考虑溢出吗?我们是否应该改用vadd_s16?

如果您不想丢失溢出信息,您应该首先
int8x8_t
int16x8_t
,然后进行求和

若你们想让结果饱和,那个么你们应该使用

Vector saturating add: vqadd -> Vr[i]:=sat<size>(Va[i]+Vb[i])
Vector halving add: vhadd -> Vr[i]:=(Va[i]+Vb[i])>>1
Vector rounding halving add: vrhadd -> Vr[i]:=(Va[i]+Vb[i]+1)>>1