public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/58928] New: Different results from gcc when -mlzcnt is used
@ 2013-10-30 20:05 mikeb01 at gmail dot com
  2013-12-10  7:06 ` [Bug target/58928] " gnome3fans at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: mikeb01 at gmail dot com @ 2013-10-30 20:05 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58928
           Summary: Different results from gcc when -mlzcnt is used
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mikeb01 at gmail dot com

Created attachment 31113
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31113&action=edit
Preprossed test.c code

I have the following code:

#include <stdint.h>
#include <stdio.h>
#include <x86intrin.h>

long long lzcnt(long long l)
{
    return __lzcnt64(l);
}

int main(int argc, char** argv)
{
    printf("%lld\n", lzcnt(atoll(argv[1])));
    return 0;
}

If I compile and run with and without the -mlzcnt flag I get different results:

$ gcc src/test.c -D__LZCNT__ -mlzcnt && ./a.out 2047
10

$ gcc src/test.c -D__LZCNT__ && ./a.out 2047
53

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/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 --with-linker-hash-style=gnu
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin
--enable-initfini-array --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-isl=/builddir/build/BUILD/gcc-4.8.2-20131017/obj-x86_64-redhat-linux/isl-install
--with-cloog=/builddir/build/BUILD/gcc-4.8.2-20131017/obj-x86_64-redhat-linux/cloog-install
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.2 20131017 (Red Hat 4.8.2-1) (GCC) 

File test.i attached.  It was the same for both compilations, so only one file
attached.


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

* [Bug target/58928] Different results from gcc when -mlzcnt is used
  2013-10-30 20:05 [Bug c/58928] New: Different results from gcc when -mlzcnt is used mikeb01 at gmail dot com
@ 2013-12-10  7:06 ` gnome3fans at gmail dot com
  2014-01-17  1:18 ` mikeb01 at gmail dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: gnome3fans at gmail dot com @ 2013-12-10  7:06 UTC (permalink / raw)
  To: gcc-bugs

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

chenjinzhi <gnome3fans at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gnome3fans at gmail dot com

--- Comment #1 from chenjinzhi <gnome3fans at gmail dot com> ---
(In reply to Michael Barker from comment #0)
> Created attachment 31113 [details]
> Preprossed test.c code
> 
> I have the following code:
> 
> #include <stdint.h>
> #include <stdio.h>
> #include <x86intrin.h>
> 
> long long lzcnt(long long l)
> {
> 	return __lzcnt64(l);
> }
> 
> int main(int argc, char** argv)
> {
> 	printf("%lld\n", lzcnt(atoll(argv[1])));
> 	return 0;
> }
> 
> If I compile and run with and without the -mlzcnt flag I get different
> results:
> 
> $ gcc src/test.c -D__LZCNT__ -mlzcnt && ./a.out 2047
> 10
> 
> $ gcc src/test.c -D__LZCNT__ && ./a.out 2047
> 53
> 
> $ gcc -v
> Using built-in specs.
> COLLECT_GCC=gcc
> COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/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 --with-linker-hash-style=gnu
> --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto
> --enable-plugin --enable-initfini-array --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-isl=/builddir/build/BUILD/gcc-4.8.2-20131017/obj-x86_64-redhat-linux/
> isl-install
> --with-cloog=/builddir/build/BUILD/gcc-4.8.2-20131017/obj-x86_64-redhat-
> linux/cloog-install --with-tune=generic --with-arch_32=i686
> --build=x86_64-redhat-linux
> Thread model: posix
> gcc version 4.8.2 20131017 (Red Hat 4.8.2-1) (GCC) 
> 
> File test.i attached.  It was the same for both compilations, so only one
> file attached.

I just test the code in my machine but the result is different from yours.
I compile and run with and without the -mlzcnt flag and get the same result:
53.

Here is my gcc -v output:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/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 --with-linker-hash-style=gnu
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin
--enable-initfini-array --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-isl=/builddir/build/BUILD/gcc-4.8.2-20131017/obj-x86_64-redhat-linux/isl-install
--with-cloog=/builddir/build/BUILD/gcc-4.8.2-20131017/obj-x86_64-redhat-linux/cloog-install
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.2 20131017 (Red Hat 4.8.2-1) (GCC)

Hope helps
>From gcc-bugs-return-437156-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Dec 10 07:06:05 2013
Return-Path: <gcc-bugs-return-437156-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 21033 invoked by alias); 10 Dec 2013 07:06:04 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 21000 invoked by uid 48); 10 Dec 2013 07:06:01 -0000
From: "conradsand.arma at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/59364] C++11 extern thread_local breaks linking: undefined reference to TLS init function
Date: Tue, 10 Dec 2013 07:06:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.8.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: major
X-Bugzilla-Who: conradsand.arma at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-59364-4-bs1gNKKsa8@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59364-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59364-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-12/txt/msg00811.txt.bz2
Content-length: 598

http://gcc.gnu.org/bugzilla/show_bug.cgi?idY364

--- Comment #3 from Conrad <conradsand.arma at gmail dot com> ---
Reduced test case.  Compile with:

g++ a.cpp -c -o a.o -std=c++11
g++ b.cpp -c -o b.o -std=c++11
g++ a.o b.o -o prog -std=c++11

file foo.hpp:

class foo
  {
  public:

  inline  foo() {}
  inline ~foo() {}

  inline double bar() { return 123.456; }
  };


file a.cpp:

#include "foo.hpp"
thread_local foo foo_instance;


file b.cpp:

#include "foo.hpp"
extern thread_local foo foo_instance;

int main(int argc, char** argv)
  {
  double bar = foo_instance.bar();
  return 0;
  }


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

* [Bug target/58928] Different results from gcc when -mlzcnt is used
  2013-10-30 20:05 [Bug c/58928] New: Different results from gcc when -mlzcnt is used mikeb01 at gmail dot com
  2013-12-10  7:06 ` [Bug target/58928] " gnome3fans at gmail dot com
@ 2014-01-17  1:18 ` mikeb01 at gmail dot com
  2014-01-17 10:31 ` jtaylor.debian at googlemail dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mikeb01 at gmail dot com @ 2014-01-17  1:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Michael Barker <mikeb01 at gmail dot com> ---
> Hope helps

What hardware platform are you testing on?  I'm running on Ivy Bridge:

Intel(R) Xeon(R) CPU E5620 @2.40GHz

Could you put the assembler that you see on the ticket:

With -mlzcnt:

0000000000400580 <lzcnt>:
  400580:    55                       push   %rbp
  400581:    48 89 e5                 mov    %rsp,%rbp
  400584:    48 89 7d e8              mov    %rdi,-0x18(%rbp)
  400588:    48 8b 45 e8              mov    -0x18(%rbp),%rax
  40058c:    48 89 45 f8              mov    %rax,-0x8(%rbp)
  400590:    f3 48 0f bd 45 f8        lzcnt  -0x8(%rbp),%rax
  400596:    48 98                    cltq   
  400598:    5d                       pop    %rbp
  400599:    c3                       retq   

Without -mlzcnt:

0000000000400580 <lzcnt>:
  400580:    55                       push   %rbp
  400581:    48 89 e5                 mov    %rsp,%rbp
  400584:    48 89 7d e8              mov    %rdi,-0x18(%rbp)
  400588:    48 8b 45 e8              mov    -0x18(%rbp),%rax
  40058c:    48 89 45 f8              mov    %rax,-0x8(%rbp)
  400590:    48 0f bd 45 f8           bsr    -0x8(%rbp),%rax
  400595:    48 83 f0 3f              xor    $0x3f,%rax
  400599:    48 98                    cltq   
  40059b:    5d                       pop    %rbp
  40059c:    c3                       retq


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

* [Bug target/58928] Different results from gcc when -mlzcnt is used
  2013-10-30 20:05 [Bug c/58928] New: Different results from gcc when -mlzcnt is used mikeb01 at gmail dot com
  2013-12-10  7:06 ` [Bug target/58928] " gnome3fans at gmail dot com
  2014-01-17  1:18 ` mikeb01 at gmail dot com
@ 2014-01-17 10:31 ` jtaylor.debian at googlemail dot com
  2014-01-17 11:16 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jtaylor.debian at googlemail dot com @ 2014-01-17 10:31 UTC (permalink / raw)
  To: gcc-bugs

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

Julian Taylor <jtaylor.debian at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jtaylor.debian at googlemail dot c
                   |                            |om

--- Comment #3 from Julian Taylor <jtaylor.debian at googlemail dot com> ---
the result will be different depending on running on amd or intel cpu.
lzcnt encoding maps to some other instruction (bsr) on intel cpus, see

http://code.google.com/p/corkami/wiki/x86oddities#lzcnt


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

* [Bug target/58928] Different results from gcc when -mlzcnt is used
  2013-10-30 20:05 [Bug c/58928] New: Different results from gcc when -mlzcnt is used mikeb01 at gmail dot com
                   ` (2 preceding siblings ...)
  2014-01-17 10:31 ` jtaylor.debian at googlemail dot com
@ 2014-01-17 11:16 ` jakub at gcc dot gnu.org
  2014-01-19  0:44 ` mikeb01 at gmail dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-01-17 11:16 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Intel(R) Xeon(R) CPU E5620 @2.40GHz
is not IvyBridge, plus even IvyBridge doesn't support lzcnt insn, only Haswell
or some recent AMD CPUs.  So, this looks like user error, you shouldn't compile
code you intend to run on non-lzcnt CPUs with -mlzcnt.


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

* [Bug target/58928] Different results from gcc when -mlzcnt is used
  2013-10-30 20:05 [Bug c/58928] New: Different results from gcc when -mlzcnt is used mikeb01 at gmail dot com
                   ` (3 preceding siblings ...)
  2014-01-17 11:16 ` jakub at gcc dot gnu.org
@ 2014-01-19  0:44 ` mikeb01 at gmail dot com
  2014-01-20 23:48 ` mikeb01 at gmail dot com
  2014-01-20 23:48 ` mikeb01 at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: mikeb01 at gmail dot com @ 2014-01-19  0:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Michael Barker <mikeb01 at gmail dot com> ---
(In reply to Jakub Jelinek from comment #4)
> Intel(R) Xeon(R) CPU E5620 @2.40GHz
> is not IvyBridge, plus even IvyBridge doesn't support lzcnt insn, only
> Haswell or some recent AMD CPUs.  So, this looks like user error, you
> shouldn't compile code you intend to run on non-lzcnt CPUs with -mlzcnt.

Sorry, shelled into the wrong machine when running the command.  Actual model
number is (i7-3770).  Happy with the explanation, please close.

There is a further issue that the bug.c code won't compile under g++, due to a
missing builtin.

/.../lzcntintrin.h:38:29: error: ‘__builtin_clzs’ was not declared in this
scope
   return __builtin_clzs (__X);

However I will raise a separate bug for that.
>From gcc-bugs-return-440872-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Jan 19 00:59:55 2014
Return-Path: <gcc-bugs-return-440872-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 6402 invoked by alias); 19 Jan 2014 00:59:54 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 6360 invoked by uid 48); 19 Jan 2014 00:59:49 -0000
From: "mikeb01 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/59874] New: Missing builtin (__builtin_clzs) when compiling with g++
Date: Sun, 19 Jan 2014 00:59:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.8.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mikeb01 at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created
Message-ID: <bug-59874-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-01/txt/msg02014.txt.bz2
Content-length: 4620

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

            Bug ID: 59874
           Summary: Missing builtin (__builtin_clzs) when compiling with
                    g++
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mikeb01 at gmail dot com

Created attachment 31888
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31888&action=edit
Preprocessed version of bug.cc

The following code:

#include <x86intrin.h>

int main(int argc, char** argv)
{
    return __lzcnt32(2047);
}

Fails to compile using g++ (works fine with gcc).  It will compile if the
-mlzcnt switch is used, but on some platforms that will generate incorrect
code.

The __builtin_clzs does not appear to be defined when using the c++ compiler. 
If I hand modify the lzcntintrin.h file and comment out the whole definition of
the __lzcnt16 intrinsic it works okay and generates the expected code.

$ g++ -v -save-temps -D__LZCNT__ bug.cc
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/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 --with-linker-hash-style=gnu
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin
--enable-initfini-array --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-isl=/builddir/build/BUILD/gcc-4.8.2-20131212/obj-x86_64-redhat-linux/isl-install
--with-cloog=/builddir/build/BUILD/gcc-4.8.2-20131212/obj-x86_64-redhat-linux/cloog-install
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.2 20131212 (Red Hat 4.8.2-7) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-D' '__LZCNT__' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-redhat-linux/4.8.2/cc1plus -E -quiet -v -D_GNU_SOURCE
-D __LZCNT__ bug.cc -mtune=generic -march=x86-64 -fpch-preprocess -o bug.ii
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-redhat-linux/4.8.2/include-fixed"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../include/c++/4.8.2

/usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../include/c++/4.8.2/x86_64-redhat-linux
 /usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../include/c++/4.8.2/backward
 /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include
 /usr/local/include
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-D' '__LZCNT__' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-redhat-linux/4.8.2/cc1plus -fpreprocessed bug.ii
-quiet -dumpbase bug.cc -mtune=generic -march=x86-64 -auxbase bug -version -o
bug.s
GNU C++ (GCC) version 4.8.2 20131212 (Red Hat 4.8.2-7) (x86_64-redhat-linux)
    compiled by GNU C version 4.8.2 20131212 (Red Hat 4.8.2-7), GMP version
5.1.1, MPFR version 3.1.1, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++ (GCC) version 4.8.2 20131212 (Red Hat 4.8.2-7) (x86_64-redhat-linux)
    compiled by GNU C version 4.8.2 20131212 (Red Hat 4.8.2-7), GMP version
5.1.1, MPFR version 3.1.1, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 489f772b6d0264e1e4c03fca513f7a0d
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/include/immintrin.h:64:0,
                 from
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/include/x86intrin.h:62,
                 from bug.cc:1:
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/include/lzcntintrin.h: In function
‘short unsigned int __lzcnt16(short unsigned int)’:
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/include/lzcntintrin.h:38:29: error:
‘__builtin_clzs’ was not declared in this scope
   return __builtin_clzs (__X);
>From gcc-bugs-return-440873-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Jan 19 02:45:09 2014
Return-Path: <gcc-bugs-return-440873-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 31131 invoked by alias); 19 Jan 2014 02:45:06 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 30821 invoked by uid 48); 19 Jan 2014 02:44:53 -0000
From: "josephlawrie at hotmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/59875] New: Weak symbols in glibc prevent optimizations
Date: Sun, 19 Jan 2014 02:45:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 4.8.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: trivial
X-Bugzilla-Who: josephlawrie at hotmail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-59875-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-01/txt/msg02015.txt.bz2
Content-length: 1655

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

            Bug ID: 59875
           Summary: Weak symbols in glibc prevent optimizations
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: trivial
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: josephlawrie at hotmail dot com

The following (weird) code changed from a stackoverflow post demonstrates the
problem:

#include <array>
#include <cassert>
#include <cstdlib>

/*
void * operator new(std::size_t n) throw(std::bad_alloc)
{
  return malloc(n);
}
void operator delete(void * p) throw()
{
if(p != nullptr)
  free(p);
}
/*

class P {
  public:
    P() : _value(nullptr) {}
    ~P() { delete _value; }

  private:
   char *_value;
};

void foo() {
  if(std::array<P, 4>().size() != 4)
    assert(false);
}

(compiled with g++ -std=c++11 -O3 -fno-weak -static -Wa,-alh test.cpp -o test)

The result of delete _value cannot be eliminated (and hence neither can array
construction, etc) even though the standard says something to the effect of
"The value of the first argument supplied to a deallocation function may be a
null pointer value; if so, and if the deallocation function is one supplied in
the standard library, the call has no effect." i.e, delete should do nothing.

I thought this has something to do with the fallback to glibc's free which can
be hooked (and hence the delete's side effect are unknown). The uncommented
version however  still contains a call to free, so it is possibly just a
constant propagation thing.
>From gcc-bugs-return-440874-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Jan 19 04:22:04 2014
Return-Path: <gcc-bugs-return-440874-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 27455 invoked by alias); 19 Jan 2014 04:22:03 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 27411 invoked by uid 48); 19 Jan 2014 04:21:57 -0000
From: "3dw4rd at verizon dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/59867] Template string literal loses first symbol
Date: Sun, 19 Jan 2014 04:22:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: 3dw4rd at verizon dot net
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-59867-4-sKs0aa9Sqf@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59867-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59867-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-01/txt/msg02016.txt.bz2
Content-length: 335

http://gcc.gnu.org/bugzilla/show_bug.cgi?idY867

--- Comment #8 from Ed Smith-Rowland <3dw4rd at verizon dot net> ---
I put this in a while back because it looked like it was going into C++14.  I
jumped to gun.  Unfortunately, I am not on a place where I can look at this
until Tuesday.

It should only be activated for -std=c++1y.


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

* [Bug target/58928] Different results from gcc when -mlzcnt is used
  2013-10-30 20:05 [Bug c/58928] New: Different results from gcc when -mlzcnt is used mikeb01 at gmail dot com
                   ` (5 preceding siblings ...)
  2014-01-20 23:48 ` mikeb01 at gmail dot com
@ 2014-01-20 23:48 ` mikeb01 at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: mikeb01 at gmail dot com @ 2014-01-20 23:48 UTC (permalink / raw)
  To: gcc-bugs

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

Michael Barker <mikeb01 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Michael Barker <mikeb01 at gmail dot com> ---
Not a bug, closed by reporter.


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

* [Bug target/58928] Different results from gcc when -mlzcnt is used
  2013-10-30 20:05 [Bug c/58928] New: Different results from gcc when -mlzcnt is used mikeb01 at gmail dot com
                   ` (4 preceding siblings ...)
  2014-01-19  0:44 ` mikeb01 at gmail dot com
@ 2014-01-20 23:48 ` mikeb01 at gmail dot com
  2014-01-20 23:48 ` mikeb01 at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: mikeb01 at gmail dot com @ 2014-01-20 23:48 UTC (permalink / raw)
  To: gcc-bugs

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

Michael Barker <mikeb01 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |INVALID


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

end of thread, other threads:[~2014-01-20 23:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-30 20:05 [Bug c/58928] New: Different results from gcc when -mlzcnt is used mikeb01 at gmail dot com
2013-12-10  7:06 ` [Bug target/58928] " gnome3fans at gmail dot com
2014-01-17  1:18 ` mikeb01 at gmail dot com
2014-01-17 10:31 ` jtaylor.debian at googlemail dot com
2014-01-17 11:16 ` jakub at gcc dot gnu.org
2014-01-19  0:44 ` mikeb01 at gmail dot com
2014-01-20 23:48 ` mikeb01 at gmail dot com
2014-01-20 23:48 ` mikeb01 at gmail dot com

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).