SSE,AVX是否不缺少? [英] Is NOT missing from SSE, AVX?

查看:86
本文介绍了SSE,AVX是否不缺少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是我的想象,还是SSE和AVX中缺少PNOT指令?也就是说,一条指令会翻转向量中的每一位.

Is it my imagination, or is a PNOT instruction missing from SSE and AVX? That is, an instruction which flips every bit in the vector.

如果是,有没有比用全1的矢量模拟PXOR更好的方法了?非常烦人,因为我需要设置一个全1的向量才能使用该方法.

If yes, is there a better way of emulating it than PXOR with a vector of all 1s? Quite annoying since I need to set up a vector of all 1s to use that approach.

推荐答案

在这种情况下,了解编译器将生成什么将很有帮助.

For cases such as this it can be instructive to see what a compiler would generate.

例如用于以下功能:

#include <immintrin.h>

__m256i test(const __m256i v)
{
  return ~v;
}

gcc和clang似乎都生成相同的代码:

both gcc and clang seem to generate much the same code:

test(long long __vector(4)):
        vpcmpeqd        ymm1, ymm1, ymm1
        vpxor   ymm0, ymm0, ymm1
        ret

这篇关于SSE,AVX是否不缺少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆