[Bug target/54201] New: XMM constant duplicated

cesarb at cesarb dot net gcc-bugzilla@gcc.gnu.org
Wed Aug 8 11:31:00 GMT 2012


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

             Bug #: 54201
           Summary: XMM constant duplicated
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: cesarb@cesarb.net


Created attachment 27960
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27960
Reduced testcase

When compiling the following small function (command line used "gcc -std=c99
-Wall -Wextra -Werror -O3 -save-temps -c pcmpeqb.c"):

#include <emmintrin.h>

__m128i test(__m128i value)
{
    __m128i mask = _mm_set1_epi8(1);
    return _mm_cmpeq_epi8(_mm_and_si128(value, mask), mask);
}

gcc creates two identical copies of the "mask" constant, one with repeated
.quad, the other with repeated .byte:

[...]
    pand    .LC0(%rip), %xmm0
    pcmpeqb    .LC1(%rip), %xmm0
[...]
    .align 16
.LC0:
    .quad    72340172838076673
    .quad    72340172838076673
    .align 16
.LC1:
    .byte    1
    .byte    1
[...]

It should create and use only one copy of the constant.

With more complex code in which "test" is a inline function called several
times, gcc uses two registers instead of one for the constant; it seems it
cannot see it is the same value, even though it is explicitly the same value in
the source code.

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.6.3/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-linker-build-id
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin
--enable-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-ppl --with-cloog --with-tune=generic --with-arch_32=i686
--build=x86_64-redhat-linux
Thread model: posix
gcc version 4.6.3 20120306 (Red Hat 4.6.3-2) (GCC)



More information about the Gcc-bugs mailing list