This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/25563] New: Assembler referenced static variable optimized out (bug in gcc or in code?)


I'm not sure whether it's a bug in gcc or rather a bug in the code. When I
compile the attached code with just "-O0" I get

$ nm test.o | grep _mmx_one
00000000 r _mmx_one

but when I compile with "-O1" the variable is probably optimized out and I get

$ nm test.o | grep _mmx_one
         U _mmx_one

If it is a wrong code, what is the proper way to handle this situation to force
gcc not to optimize the static variable out completely?

--- test.c -----------------------------------------
static short const _mmx_one[] = { 1, 1, 1, 1 };

void mmx_interpolate(unsigned char **ref,
       int pitch,
       int rounding)
{
  int dummy = 0;
  short _mmx_rc[4];
  register short *rc = _mmx_rc;

  _mmx_rc[0] = 1 - rounding;
  _mmx_rc[1] = 1 - rounding;
  _mmx_rc[2] = 1 - rounding;
  _mmx_rc[3] = 1 - rounding;

  asm volatile ("movl (%0), %3\n"
  "pxor %%mm7, %%mm7\n"
  "movq (%3), %%mm0\n"
  "movq 1(%3), %%mm1\n"
  "movq %%mm0, %%mm2\n"
  "movq %%mm1, %%mm3\n"
  "punpcklbw %%mm7, %%mm0\n"
  "punpcklbw %%mm7, %%mm1\n"
  "punpckhbw %%mm7, %%mm2\n"
  "punpckhbw %%mm7, %%mm3\n"
  "movq %%mm0, %%mm4\n"
  "movq %%mm2, %%mm5\n"
  "paddw %%mm1, %%mm0\n"
  "paddw %%mm3, %%mm2\n"
  "paddw (%2), %%mm0\n"
  "paddw (%2), %%mm2\n"
  "psrlw $1, %%mm2\n"
  "psrlw $1, %%mm0\n"
  "packuswb %%mm2, %%mm0\n"
  "movq (%3, %1), %%mm1\n"
  "movq 1(%3, %1), %%mm3\n"
  "movq %%mm1, %%mm2\n"
  "movq %%mm3, %%mm6\n"
  "punpcklbw %%mm7, %%mm1\n"
  "punpcklbw %%mm7, %%mm3\n"
  "punpckhbw %%mm7, %%mm2\n"
  "punpckhbw %%mm7, %%mm6\n"
  "paddw %%mm1, %%mm4\n"
  "paddw %%mm2, %%mm5\n"
  "paddw (%2), %%mm4\n"
  "paddw (%2), %%mm5\n"
  "paddw %%mm4, %%mm3\n"
  "paddw %%mm5, %%mm6\n"
  "psrlw $1, %%mm4\n"
  "psrlw $1, %%mm5\n"
  "paddw " "_mmx_one, %%mm3\n"
  "paddw " "_mmx_one, %%mm6\n"
  "packuswb %%mm5, %%mm4\n"
  "movq 1(%3), %%mm1\n"
  "movq %%mm1, %%mm2\n"
  "punpcklbw %%mm7, %%mm1\n"
  "punpckhbw %%mm7, %%mm2\n"
  "paddw %%mm1, %%mm3\n"
  "paddw %%mm2, %%mm6\n"
  "psrlw $2, %%mm3\n"
  "psrlw $2, %%mm6\n"
  "packuswb %%mm6, %%mm3\n"
  "movl 4(%0), %3\n"
  "movq %%mm0, (%3)\n"
  "movl 8(%0), %3\n"
  "movq %%mm4, (%3)\n"
  "movl 12(%0), %3\n"
  "movq %%mm3, (%3)\n"
  : "=r"(ref), "=r"(pitch), "=r"(rc), "=r"(dummy)
  : "0"(ref), "1"(pitch), "2"(rc), "3"(dummy)
  : "memory");
}
----------------------------------------------------


-- 
           Summary: Assembler referenced static variable optimized out (bug
                    in gcc or in code?)
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: drab at kepler dot fjfi dot cvut dot cz


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25563


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]