This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

neon的vabs_s16指令是不是会丢失-32768

RT

Parents
  •  vabs_s16会保留-32768。

    我在aarch64下测试如下代码:

    #include <arm_neon.h>
    #include <stdio.h>
    #include <stdint.h>
    
    int16_t foo(int16_t x) {
      int16x8_t ax;
      for (int i; i < 8; i++) {
        ax[i] = x;
      }
    
      ax = vabsq_s16(ax);
      return ax[0];
    }
    
    int main(void) {
      int16_t x1 = -32768;
      int16_t x2 = -32767;
      printf("%d\n", foo(x1));
      printf("%d\n", foo(x2));
      return 0;
    }
    

    输出:

    -32768
    32767

Reply
  •  vabs_s16会保留-32768。

    我在aarch64下测试如下代码:

    #include <arm_neon.h>
    #include <stdio.h>
    #include <stdint.h>
    
    int16_t foo(int16_t x) {
      int16x8_t ax;
      for (int i; i < 8; i++) {
        ax[i] = x;
      }
    
      ax = vabsq_s16(ax);
      return ax[0];
    }
    
    int main(void) {
      int16_t x1 = -32768;
      int16_t x2 = -32767;
      printf("%d\n", foo(x1));
      printf("%d\n", foo(x2));
      return 0;
    }
    

    输出:

    -32768
    32767

Children
No data