public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/54201] New: XMM constant duplicated
@ 2012-08-08 11:31 cesarb at cesarb dot net
  2012-08-08 11:32 ` [Bug target/54201] " cesarb at cesarb dot net
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: cesarb at cesarb dot net @ 2012-08-08 11:31 UTC (permalink / raw)
  To: gcc-bugs

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)


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-08-21 23:28 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-08 11:31 [Bug target/54201] New: XMM constant duplicated cesarb at cesarb dot net
2012-08-08 11:32 ` [Bug target/54201] " cesarb at cesarb dot net
2012-08-08 11:53 ` [Bug middle-end/54201] " rguenth at gcc dot gnu.org
2012-08-08 23:29 ` cesarb at cesarb dot net
2012-08-09  9:50 ` rguenth at gcc dot gnu.org
2012-08-09 10:22 ` rguenth at gcc dot gnu.org
2012-08-13 12:43 ` rguenth at gcc dot gnu.org
2012-08-14 13:21 ` rguenth at gcc dot gnu.org
2012-08-14 14:38 ` rguenth at gcc dot gnu.org
2012-08-15  9:03 ` rguenth at gcc dot gnu.org
2020-08-31  8:30 ` cvs-commit at gcc dot gnu.org
2020-08-31 17:20 ` jakub at gcc dot gnu.org
2021-08-21 23:24 ` pinskia at gcc dot gnu.org
2021-08-21 23:28 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).