|
From: John R.
|
>>> insn_sse.c:4602:11: error: invalid operand for instruction >>> "pextrw $0, %%mm6, %%r9\n" >>> ^ >>> <inline asm>:7:1: note: instantiated into assembly here >>> pextrw $0, %mm6, %r9 >>> ^ >> This is legal code. If clang rejects the code, then clang has a bug. > clang wants you to write %r9d instead of %r9. Quoting from Intel® 64 and IA-32 Architectures Software Developer’s Manual Combined Volumes: 1, 2A, 2B, 2C, 3A, 3B and 3C; Order Number: 325462-041US December 2011; Vol. 2B page 4-251 (.pdf page 1469): [http://developer.intel.com] If the destination operand is a general-purpose register, the default operand size is 64-bits in 64-bit mode. By that documentation, in 64-bit mode "%r9" is correct (a 64-bit destination) and "%r9d" is incorrect (a 32-bit destination.) Even if "%r9d" was "more correct", in 64-bit mode every write of a 32-bit value to a 64-bit general-purpose register actually writes all 64 bits, and almost always zero-extends. Thus all 64 bits get written, and when by 'pextrw' then the high 48 bits will be zero. The clever programmer cannot preserve the previous value of bits 63:32. So the hardware writes all 64 bits of %r9 independent of whether the software calls the destination "%r9" or "%r9d"; and for 'pextrw' only the low 16 bits can possibly be non-zero. -- |