c++/4999: asm code with concatenated content fails in template class member functions

sethml@ofb.net sethml@ofb.net
Mon Dec 3 21:29:00 GMT 2001


>     I don't think you have valid asm.  Here is what gcc 3.0.3 (prerelease)
>     says when I try to compile your code:

Uh, I filed the bug report against 2.95.4, not 3.0.  It looks like
gcc-3.0 became more strict about stray '%'s in code.  If I fix the
'%'s, the problem remains.  Note that it is only a problem with 2.95 -
apparently it's been fixed in 3.0.  I'm making the assumption that
2.95 is still being actively maintained.

Here's a version that compiles under gcc-3.0, but breaks gcc-2.95.4:

  template <class X> struct test {
    static int foo(int *b1, int *b2) {
      __asm__ ("movq" " %0, %%" "mm2" : : "m" (*(long long *)b1));
      __asm__ ("movq" " %%" "mm2" ", %%" "mm3")  ;
      __asm__ ("punpckhbw" " %%" "mm0" ", %%" "mm2")  ;
      __asm__ ("punpckhbw" " %%" "mm0" ", %%" "mm3")  ;
      __asm__ ("movq" " %0, %%" "mm4" : : "m" (*(long long *)b2));
      __asm__ ("movq" " %%" "mm4" ", %%" "mm5")  ;
      __asm__ ("punpckhbw" " %%" "mm0" ", %%" "mm4")  ;
      __asm__ ("punpckhbw" " %%" "mm0" ", %%" "mm5")  ;
      __asm__ ("psubsw" " %%" "mm4" ", %%" "mm2")  ;
      __asm__ ("psubsw" " %%" "mm5" ", %%" "mm3")  ;
      __asm__ ("pmaddwd" " %%" "mm2" ", %%" "mm2")  ;
      __asm__ ("pmaddwd" " %%" "mm3" ", %%" "mm3")  ;
      __asm__ ("paddd" " %%" "mm2" ", %%" "mm1")  ;
      __asm__ ("paddd" " %%" "mm3" ", %%" "mm1")  ;
    }
  };

  int main(int argc) {
    test<int>::foo(&argc, &argc);
  }

Seth



More information about the Gcc-bugs mailing list