[FFmpeg-devel] CDQ vs. CLTD

Reimar Döffinger Reimar.Doeffinger
Wed Feb 27 20:54:40 CET 2008


On Wed, Feb 27, 2008 at 08:37:16PM +0100, Michael Niedermayer wrote:
> On Wed, Feb 27, 2008 at 08:06:59PM +0100, Reimar D?ffinger wrote:
> > I just found out that gcc (actually, binutils) seems to support "cltd"
> > instead of of "cdq", and Sun C (as of SunStudio 12) supports only the former.
> 
> > Since at least the AMD manuals do not have cltd but only cdq I am
> 
> intel/amd official and clean syntax != gnu AT&T syntax
> 
> > reluctant to suggest changing it, but I'm still interesting if you have
> > any comments on this or suggestions.
> 
> feel free to change it if it works with normal gnu binutils

I tested with gcc 4.1.2, 2.95, and icc 10.1.008, all seem to work with
cltd.
If there are no objections I will then apply the attached patch
somewhen.

Greetings,
Reimar D?ffinger
-------------- next part --------------
Index: libavcodec/cabac.h
===================================================================
--- libavcodec/cabac.h	(revision 12187)
+++ libavcodec/cabac.h	(working copy)
@@ -327,7 +327,7 @@
     //P3:665    athlon:517
     asm(
         "lea -0x100(%0), %%eax      \n\t"
-        "cdq                        \n\t"
+        "cltd                       \n\t"
         "mov %0, %%eax              \n\t"
         "and %%edx, %0              \n\t"
         "and %1, %%edx              \n\t"
@@ -599,7 +599,7 @@
         "shl $17, %%ebx                         \n\t"
         "add %%eax, %%eax                       \n\t"
         "sub %%ebx, %%eax                       \n\t"
-        "cdq                                    \n\t"
+        "cltd                                   \n\t"
         "and %%edx, %%ebx                       \n\t"
         "add %%ebx, %%eax                       \n\t"
         "test %%ax, %%ax                        \n\t"
@@ -646,7 +646,7 @@
         "shl $17, %%ebx                         \n\t"
         "add %%eax, %%eax                       \n\t"
         "sub %%ebx, %%eax                       \n\t"
-        "cdq                                    \n\t"
+        "cltd                                   \n\t"
         "and %%edx, %%ebx                       \n\t"
         "add %%ebx, %%eax                       \n\t"
         "xor %%edx, %%ecx                       \n\t"
Index: libavutil/internal.h
===================================================================
--- libavutil/internal.h	(revision 12187)
+++ libavutil/internal.h	(working copy)
@@ -205,7 +205,7 @@
 #if defined(ARCH_X86)
 #define MASK_ABS(mask, level)\
             asm volatile(\
-                "cdq                    \n\t"\
+                "cltd                   \n\t"\
                 "xorl %1, %0            \n\t"\
                 "subl %1, %0            \n\t"\
                 : "+a" (level), "=&d" (mask)\



More information about the ffmpeg-devel mailing list