0

Something bugs me regarding the vector extensions.

The document: Intel® Advanced Vector Extensions Programming Reference

States:

VPSRLD ymm1, ymm2, imm8

So I went ahead and:

__asm__ (
    "vpsrld %ymm0, %ymm0, $0x4"
);

GCC 4.8.2-19ubuntu1 spits out:

Error: operand type mismatch for `vpsrld'

Then after googling without any findings I started changing stuff around and this compiles:

__asm__ (
    "vpsrld  $0x4, %ymm0, %ymm0"
);

Anyone has any idea why anyone would change order compared to the reference guide?

Thank you for any help.

n0p
  • 3,399
  • 2
  • 29
  • 50
Anders Cedronius
  • 2,036
  • 1
  • 23
  • 29
  • 2
    Search for AT&T vs Intel syntax. – Marc Glisse Jun 03 '14 at 14:33
  • 2
    Have you considered using intrinsics instead? e.g. [_mm256_srli_epi32](https://software.intel.com/sites/products/documentation/studio/composer/en-us/2011Update/compiler_c/intref_cls/common/intref_avx2_srli_epi.htm) – Brett Hale Jun 03 '14 at 15:47
  • +1 for the suggestion of using intrinsics instead of raw asm - it will save a lot of time and pain. – Paul R Jun 03 '14 at 16:38

1 Answers1

2

I think that's because the GNU Assembler that's being used most often in the GCC toolchain uses the AT&T assembler syntax, which has a different operand order than the Intel one.

For example mov eax, 5 in Intel format becomes mov $5, %eax in AT&T.

You can find some information about those two version on Wikipedia.

Dirk
  • 10,668
  • 2
  • 35
  • 49