Package: uqm
Version: 0.6.2.dfsg-9.3
Severity: serious
Justification: fails to build from source (but built successfully in the past)
Forwarded: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78311

Hi,

uqm started to FTBFS after the switch of the default compiler from gcc-5 to 
gcc-6.

gcc -c  -o "obj/release/src/sc2code/libs/graphics/sdl/2xscalers_mmx.c.o" -g -O2 
-fdebug-prefix-map=/build/uqm-0.6.2.dfsg=. -fstack-protector-strong -Wformat 
-Werror=format-security -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT 
-I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -O3 -DGFXMODULE_SDL 
-DHAVE_OPENGL  -DSOUNDMODULE_SDL   -DNETPLAY=NETPLAY_FULL -DHAVE_JOYSTICK 
-DHAVE_ZIP=1  -DUSE_PLATFORM_ACCEL -I "." -g -Wdate-time -D_FORTIFY_SOURCE=2 -I 
src -I src/sc2code -I src/sc2code/libs 
"src/sc2code/libs/graphics/sdl/2xscalers_mmx.c"
src/sc2code/libs/graphics/sdl/scalemmx.h: Assembler messages:
src/sc2code/libs/graphics/sdl/scalemmx.h:638: Error: register value used as 
expression
src/sc2code/libs/graphics/sdl/scalemmx.h:640: Error: register value used as 
expression
src/sc2code/libs/graphics/sdl/scalemmx.h:638: Error: register value used as 
expression
src/sc2code/libs/graphics/sdl/scalemmx.h:640: Error: register value used as 
expression
[...]

That's in an inline assembly block ... I've marked the
problematic lines with ***

// compare 2 pixels with respect to their YUV representations
// tolerance set by toler arg
// returns true: close; false: distant (-gt toler)
static inline bool
SCALE_(CmpYUV) (Uint32 pix1, Uint32 pix2, int toler)
{
        int delta;

        __asm__ (
                "movd       %1, %%mm1 \n\t"
                "movd       %2, %%mm3 \n\t"

                // convert RGB888 to 555
                // this is somewhat parallelized
                "punpcklbw  %%mm0, %%mm1 \n\t"
                CLR_UPPER32 (A_REG)     "\n\t"
                "psrlw      $3, %%mm1    \n\t"   // 8->5 bit
                "punpcklbw  %%mm0, %%mm3 \n\t"
                "psrlw      $3, %%mm3    \n\t" // 8->5 bit
                "pmaddwd    %4, %%mm1    \n\t" // shuffle into the right 
channel order
                "movq       %%mm1, %%mm2 \n\t"  // finish shuffling
                "pmaddwd    %4, %%mm3    \n\t" // shuffle into the right 
channel order
                CLR_UPPER32 (D_REG)     "\n\t"
                "movq       %%mm3, %%mm4 \n\t"  // finish shuffling
                "punpckhdq  %%mm0, %%mm2 \n\t"  //   ditto
                "por        %%mm2, %%mm1 \n\t"  //   ditto
                "punpckhdq  %%mm0, %%mm4 \n\t"  //   ditto
                "por        %%mm4, %%mm3 \n\t"  //   ditto

                // lookup the YUV vector
                "movd       %%mm1, %%eax \n\t"
                "movd       %%mm3, %%edx \n\t"
                //movd      (%3, %%eax, 4), %%mm1
***             MOVD_WMO    (%3, "%%" A_REG, 4, %%mm1) "\n\t"
                "movq       %%mm1, %%mm4 \n\t"
                //movd      (%3, %%edx, 4), %%mm2
***             MOVD_WMO    (%3, "%%" D_REG, 4, %%mm2) "\n\t"

                // get abs difference between YUV components
#ifdef USE_PSADBW
                // we can use PSADBW and save us some grief
                "psadbw     %%mm2, %%mm1 \n\t"
                "movd       %%mm1, %0    \n\t"
#else
                // no PSADBW -- have to do it the hard way
                "psubusb    %%mm2, %%mm1 \n\t"
                "psubusb    %%mm4, %%mm2 \n\t"
                "por        %%mm2, %%mm1 \n\t"

                // sum the differences
                //  technically, this produces a MAX diff of 510
                //  but we do not need anything bigger, currently
                "movq       %%mm1, %%mm2 \n\t"
                "psrlq      $8, %%mm2    \n\t"
                "paddusb    %%mm2, %%mm1 \n\t"
                "psrlq      $8, %%mm2    \n\t"
                "paddusb    %%mm2, %%mm1 \n\t"
                // store intermediate delta
                "movd       %%mm1, %0    \n\t"
                "andl       $0xff, %0    \n\t"
#endif /* USE_PSADBW */
        : /*0*/"=r" (delta)
        : /*1*/"rm" (pix1), /*2*/"rm" (pix2),
                /*3*/OFFSETABLE_PTR(RGB15_to_YUV),
                /*4*/"m" (mmx_888to555_mult)
        : "%" A_REG, "%" D_REG
        );

        return (delta << 1) <= toler;
}

This was preprocessed with gcc-5:

static __inline__ bool
Scale_MMX_CmpYUV (Uint32 pix1, Uint32 pix2, int toler)
{
 int delta;

 __asm__ (
  "movd       %1, %%mm1 \n\t"
  "movd       %2, %%mm3 \n\t"



  "punpcklbw  %%mm0, %%mm1 \n\t"
  "\n\t"
  "psrlw      $3, %%mm1    \n\t"
  "punpcklbw  %%mm0, %%mm3 \n\t"
  "psrlw      $3, %%mm3    \n\t"
  "pmaddwd    %4, %%mm1    \n\t"
  "movq       %%mm1, %%mm2 \n\t"
  "pmaddwd    %4, %%mm3    \n\t"
  "\n\t"
  "movq       %%mm3, %%mm4 \n\t"
  "punpckhdq  %%mm0, %%mm2 \n\t"
  "por        %%mm2, %%mm1 \n\t"
  "punpckhdq  %%mm0, %%mm4 \n\t"
  "por        %%mm4, %%mm3 \n\t"


  "movd       %%mm1, %%eax \n\t"
  "movd       %%mm3, %%edx \n\t"

***  "movd " "%3" "(," "%%" "eax" "," "4" ")," "%%mm1" "\n\t"
  "movq       %%mm1, %%mm4 \n\t"

***  "movd " "%3" "(," "%%" "edx" "," "4" ")," "%%mm2" "\n\t"
# 657 "src/sc2code/libs/graphics/sdl/scalemmx.h"
  "psubusb    %%mm2, %%mm1 \n\t"
  "psubusb    %%mm4, %%mm2 \n\t"
  "por        %%mm2, %%mm1 \n\t"




  "movq       %%mm1, %%mm2 \n\t"
  "psrlq      $8, %%mm2    \n\t"
  "paddusb    %%mm2, %%mm1 \n\t"
  "psrlq      $8, %%mm2    \n\t"
  "paddusb    %%mm2, %%mm1 \n\t"

  "movd       %%mm1, %0    \n\t"
  "andl       $0xff, %0    \n\t"

 : "=r" (delta)
 : "rm" (pix1), "rm" (pix2),
       "o" (*(RGB15_to_YUV)),
       "m" (mmx_888to555_mult)
 : "%" "eax", "%" "edx"
 );

 return (delta << 1) <= toler;
}

This was preprocessed by gcc-6:

static __inline__ bool
Scale_MMX_CmpYUV (Uint32 pix1, Uint32 pix2, int toler)
{
 int delta;

 __asm__ (
  "movd       %1, %%mm1 \n\t"
  "movd       %2, %%mm3 \n\t"



  "punpcklbw  %%mm0, %%mm1 \n\t"
  "\n\t"
  "psrlw      $3, %%mm1    \n\t"
  "punpcklbw  %%mm0, %%mm3 \n\t"
  "psrlw      $3, %%mm3    \n\t"
  "pmaddwd    %4, %%mm1    \n\t"
  "movq       %%mm1, %%mm2 \n\t"
  "pmaddwd    %4, %%mm3    \n\t"
  "\n\t"
  "movq       %%mm3, %%mm4 \n\t"
  "punpckhdq  %%mm0, %%mm2 \n\t"
  "por        %%mm2, %%mm1 \n\t"
  "punpckhdq  %%mm0, %%mm4 \n\t"
  "por        %%mm4, %%mm3 \n\t"


  "movd       %%mm1, %%eax \n\t"
  "movd       %%mm3, %%edx \n\t"

***  "movd " "%3" "(," "%%" "eax" "," "4" ")," "%%mm1" "\n\t"
  "movq       %%mm1, %%mm4 \n\t"

***  "movd " "%3" "(," "%%" "edx" "," "4" ")," "%%mm2" "\n\t"
# 657 "src/sc2code/libs/graphics/sdl/scalemmx.h"
  "psubusb    %%mm2, %%mm1 \n\t"
  "psubusb    %%mm4, %%mm2 \n\t"
  "por        %%mm2, %%mm1 \n\t"




  "movq       %%mm1, %%mm2 \n\t"
  "psrlq      $8, %%mm2    \n\t"
  "paddusb    %%mm2, %%mm1 \n\t"
  "psrlq      $8, %%mm2    \n\t"
  "paddusb    %%mm2, %%mm1 \n\t"

  "movd       %%mm1, %0    \n\t"
  "andl       $0xff, %0    \n\t"

 : "=r" (delta)
 : "rm" (pix1), "rm" (pix2),
       "o" (*(RGB15_to_YUV)),
       "m" (mmx_888to555_mult)
 : "%" "eax", "%" "edx"
 );

 return (delta << 1) <= toler;
}


This is how it looks after being compiled to .s with gcc-5:

# 620 "src/sc2code/libs/graphics/sdl/scalemmx.h" 1
        movd       %ebx, %mm1
        movd       %ebp, %mm3
        punpcklbw  %mm0, %mm1

        psrlw      $3, %mm1
        punpcklbw  %mm0, %mm3
        psrlw      $3, %mm3
        pmaddwd    mmx_888to555_mult, %mm1
        movq       %mm1, %mm2
        pmaddwd    mmx_888to555_mult, %mm3

        movq       %mm3, %mm4
        punpckhdq  %mm0, %mm2
        por        %mm2, %mm1
        punpckhdq  %mm0, %mm4
        por        %mm4, %mm3
        movd       %mm1, %eax
        movd       %mm3, %edx
***     movd RGB15_to_YUV(,%eax,4),%mm1
        movq       %mm1, %mm4
***     movd RGB15_to_YUV(,%edx,4),%mm2
        psubusb    %mm2, %mm1
        psubusb    %mm4, %mm2
        por        %mm2, %mm1
        movq       %mm1, %mm2
        psrlq      $8, %mm2
        paddusb    %mm2, %mm1
        psrlq      $8, %mm2
        paddusb    %mm2, %mm1
        movd       %mm1, %ebp
        andl       $0xff, %ebp

and this was generated by gcc-6:

# 620 "src/sc2code/libs/graphics/sdl/scalemmx.h" 1
        movd       %ebx, %mm1
        movd       %ebp, %mm3
        punpcklbw  %mm0, %mm1

        psrlw      $3, %mm1
        punpcklbw  %mm0, %mm3
        psrlw      $3, %mm3
        pmaddwd    (%esi), %mm1
        movq       %mm1, %mm2
        pmaddwd    (%esi), %mm3

        movq       %mm3, %mm4
        punpckhdq  %mm0, %mm2
        por        %mm2, %mm1
        punpckhdq  %mm0, %mm4
        por        %mm4, %mm3
        movd       %mm1, %eax
        movd       %mm3, %edx
***     movd (%edi)(,%eax,4),%mm1
        movq       %mm1, %mm4
***     movd (%edi)(,%edx,4),%mm2
        psubusb    %mm2, %mm1
        psubusb    %mm4, %mm2
        por        %mm2, %mm1
        movq       %mm1, %mm2
        psrlq      $8, %mm2
        paddusb    %mm2, %mm1
        psrlq      $8, %mm2
        paddusb    %mm2, %mm1
        movd       %mm1, %ebp
        andl       $0xff, %ebp


OK, since this looks like a regression in gcc, I've filed
PR78311 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78311

Andreas

Reply via email to