[Bug c++/64150] New: Missed optimisation opportunity with moved-from pimpl classes and a nullptr d-pointer

marc at kdab dot com gcc-bugzilla@gcc.gnu.org
Tue Dec 2 12:33:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64150

            Bug ID: 64150
           Summary: Missed optimisation opportunity with moved-from pimpl
                    classes and a nullptr d-pointer
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marc at kdab dot com

Created attachment 34162
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34162&action=edit
Sample program

When compiling attached sample program to assembler source, the compiler emits
two calls to destroy(), one for p1 and one for p2. However, it should be
statically clear that p1.d == nullptr, always, so dead code elimination should
remove the check for nullptr, the branch and the call to destroy().

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/opt/gcc/trunk/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --prefix=/opt/gcc/trunk
--program-suffix=-trunk --enable-checking=release
--enable-languages=c,c++,go,fortran,objc,obj-c++ : (reconfigured)
../gcc/configure --prefix=/opt/gcc/trunk --enable-checking=release
--enable-languages=c,c++,go,fortran,objc,obj-c++
Thread model: posix
gcc version 5.0.0 20141015 (experimental) (GCC)



More information about the Gcc-bugs mailing list