public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/56573] New: GCC generates non-optimal transactional code when inlining nested transaction.
@ 2013-03-08 12:58 srdjan.stipic at gmail dot com
  2013-12-09 16:20 ` [Bug c/56573] " aldyh at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: srdjan.stipic at gmail dot com @ 2013-03-08 12:58 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56573
           Summary: GCC generates non-optimal transactional code when
                    inlining nested transaction.
    Classification: Unclassified
           Product: gcc
           Version: trans-mem
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: srdjan.stipic@gmail.com


Created attachment 29621
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29621
Minimal test case.

GCC generates non-optimal transactional code
when inlining function that has transactional code.
This affects gcc-4.7 and gcc-4.8 (gcc version 4.8.0 20130222 (experimental)).

// example
int a;

static inline void f() {
  __transaction_atomic {
    ++a;
  }
}

void g() {
  __transaction_atomic {
    f();
  }
}

void h() {
  __transaction_atomic {
    __transaction_atomic {
      ++a;
    }
  }  
}

Generated code:

g():
    subq    $8, %rsp
    movl    $41, %edi
    xorl    %eax, %eax
    call    _ITM_beginTransaction
    movl    $41, %edi
    xorl    %eax, %eax
    call    _ITM_beginTransaction
    movl    $a, %edi
    call    _ITM_RfWU4
    leal    1(%rax), %esi
    movl    $a, %edi
    call    _ITM_WaWU4
    call    _ITM_commitTransaction
    call    _ITM_commitTransaction
    addq    $8, %rsp
    ret
h():
    subq    $8, %rsp
    movl    $41, %edi
    xorl    %eax, %eax
    call    _ITM_beginTransaction
    movl    $a, %edi
    call    _ITM_RfWU4
    leal    1(%rax), %esi
    movl    $a, %edi
    call    _ITM_WaWU4
    call    _ITM_commitTransaction
    addq    $8, %rsp
    ret


The bug:
The functions g() and h() should have the __same__ asm.
The problem is that GCC doesn't remove __nested__
_ITM_beginTransaction()/_ITM_commitTransaction
that are known at compile time.

Compiled with:

gcc-4.7 -v -O2 -fgnu-tm -c example.c 
Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.7.2-5ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.7 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object
--enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-5ubuntu1) 
COLLECT_GCC_OPTIONS='-v' '-O2' '-fgnu-tm' '-c' '-mtune=generic' '-march=x86-64'
'-pthread'
 /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1 -quiet -v -imultiarch x86_64-linux-gnu
-D_REENTRANT example.c -quiet -dumpbase example.c -mtune=generic -march=x86-64
-auxbase example -O2 -version -fgnu-tm -fstack-protector -o /tmp/ccKJdU1H.s
GNU C (Ubuntu/Linaro 4.7.2-5ubuntu1) version 4.7.2 (x86_64-linux-gnu)
    compiled by GNU C version 4.7.2, GMP version 5.0.2, MPFR version 3.1.0-p3,
MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/4.7/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C (Ubuntu/Linaro 4.7.2-5ubuntu1) version 4.7.2 (x86_64-linux-gnu)
    compiled by GNU C version 4.7.2, GMP version 5.0.2, MPFR version 3.1.0-p3,
MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: fbb4af59dce4dce949ee30395742b8d0
COLLECT_GCC_OPTIONS='-v' '-O2' '-fgnu-tm' '-c' '-mtune=generic' '-march=x86-64'
'-pthread'
 as -v --64 -o example.o /tmp/ccKJdU1H.s
GNU assembler version 2.22.90 (x86_64-linux-gnu) using BFD version (GNU
Binutils for Ubuntu) 2.22.90.20120924
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-O2' '-fgnu-tm' '-c' '-mtune=generic' '-march=x86-64'
'-pthread'


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

* [Bug c/56573] GCC generates non-optimal transactional code when inlining nested transaction.
  2013-03-08 12:58 [Bug c/56573] New: GCC generates non-optimal transactional code when inlining nested transaction srdjan.stipic at gmail dot com
@ 2013-12-09 16:20 ` aldyh at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: aldyh at gcc dot gnu.org @ 2013-12-09 16:20 UTC (permalink / raw)
  To: gcc-bugs

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

Aldy Hernandez <aldyh at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |aldyh at gcc dot gnu.org
         Resolution|---                         |DUPLICATE

--- Comment #1 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
Duplicate, according to comment by Patrick Marlier.

*** This bug has been marked as a duplicate of bug 56572 ***


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

end of thread, other threads:[~2013-12-09 16:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-08 12:58 [Bug c/56573] New: GCC generates non-optimal transactional code when inlining nested transaction srdjan.stipic at gmail dot com
2013-12-09 16:20 ` [Bug c/56573] " aldyh 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).