From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32390 invoked by alias); 25 Jan 2011 16:28:10 -0000 Received: (qmail 32302 invoked by uid 22791); 25 Jan 2011 16:28:08 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 25 Jan 2011 16:28:00 +0000 From: "manuel.holtgrewe@fu-berlin.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/47460] New: Inconsistent behaviour of __sync_fetch_and_add builtin? X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: manuel.holtgrewe@fu-berlin.de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Tue, 25 Jan 2011 16:34:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-01/txt/msg02671.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47460 Summary: Inconsistent behaviour of __sync_fetch_and_add builtin? Product: gcc Version: 4.4.5 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: manuel.holtgrewe@fu-berlin.de I get the unexpected (for me) inconsistent behaviour of the __sync_fetch_and_add builtin with the program below. My main confusion is around the missing __sync_val_compare_and_swap_{1,2,4} when not explicitely specifying the architecture in GCC 4.4.5, but availability in all other tried variants. Also, why is there a 64-bit variant when explicitely giving -march=i686 to g++ >=4.2 but missing one in g++-4.1? Thanks! Program gcc-atomic.cpp --8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8< template void test() { T volatile x = 0; T y = 0; T z = 0; __sync_fetch_and_add(&x, y, z); __sync_fetch_and_or(&x, y, z); __sync_fetch_and_xor(&x, y, z); __sync_val_compare_and_swap(&x, y, z); } int main() { test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); return 0; } Output WITH -march=i686 switch --8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8< $ for i in 1 2 3 4 5; do g++-4.$i --version; g++-4.$i -dumpmachine; g++-4.$i -march=i686 gcc-atomic.cpp; done g++-4.1 (GCC) 4.1.3 20080704 (prerelease) (Debian 4.1.2-25) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. i486-linux-gnu /tmp/cce8mfQl.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x46): undefined reference to `__sync_fetch_and_add_8' gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x5f): undefined reference to `__sync_fetch_and_or_8' gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x78): undefined reference to `__sync_fetch_and_xor_8' gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x9f): undefined reference to `__sync_val_compare_and_swap_8' /tmp/cce8mfQl.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x45): undefined reference to `__sync_fetch_and_add_8' gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x5e): undefined reference to `__sync_fetch_and_or_8' gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x77): undefined reference to `__sync_fetch_and_xor_8' gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x9e): undefined reference to `__sync_val_compare_and_swap_8' collect2: ld returned 1 exit status g++-4.2 (GCC) 4.2.4 (Debian 4.2.4-6) Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. i486-linux-gnu g++-4.3 (Debian 4.3.2-1.1) 4.3.2 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. i486-linux-gnu g++-4.4.5 (GCC) 4.4.5 Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. i686-pc-linux-gnu g++-4.5.1 (GCC) 4.5.1 Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. i686-pc-linux-gnu Output WITHOUT -march=i686 switch --8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8< $ for i in 1 2 3 4 5; do g++-4.$i --version; g++-4.$i -dumpmachine; g++-4.$i gcc-atomic.cpp; done g++-4.1 (GCC) 4.1.3 20080704 (prerelease) (Debian 4.1.2-25) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. i486-linux-gnu /tmp/ccGnLtMn.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x46): undefined reference to `__sync_fetch_and_add_8' gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x5f): undefined reference to `__sync_fetch_and_or_8' gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x78): undefined reference to `__sync_fetch_and_xor_8' gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x9f): undefined reference to `__sync_val_compare_and_swap_8' /tmp/ccGnLtMn.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x45): undefined reference to `__sync_fetch_and_add_8' gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x5e): undefined reference to `__sync_fetch_and_or_8' gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x77): undefined reference to `__sync_fetch_and_xor_8' gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x9e): undefined reference to `__sync_val_compare_and_swap_8' collect2: ld returned 1 exit status g++-4.2 (GCC) 4.2.4 (Debian 4.2.4-6) Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. i486-linux-gnu /tmp/ccgFK94L.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x46): undefined reference to `__sync_fetch_and_add_8' gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x5f): undefined reference to `__sync_fetch_and_or_8' gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x78): undefined reference to `__sync_fetch_and_xor_8' gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x9f): undefined reference to `__sync_val_compare_and_swap_8' /tmp/ccgFK94L.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x45): undefined reference to `__sync_fetch_and_add_8' gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x5e): undefined reference to `__sync_fetch_and_or_8' gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x77): undefined reference to `__sync_fetch_and_xor_8' gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x9e): undefined reference to `__sync_val_compare_and_swap_8' collect2: ld returned 1 exit status g++-4.3 (Debian 4.3.2-1.1) 4.3.2 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. i486-linux-gnu /tmp/ccM6VgC4.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x46): undefined reference to `__sync_fetch_and_add_8' gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x5f): undefined reference to `__sync_fetch_and_or_8' gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x78): undefined reference to `__sync_fetch_and_xor_8' gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x9f): undefined reference to `__sync_val_compare_and_swap_8' /tmp/ccM6VgC4.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x45): undefined reference to `__sync_fetch_and_add_8' gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x5e): undefined reference to `__sync_fetch_and_or_8' gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x77): undefined reference to `__sync_fetch_and_xor_8' gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x9e): undefined reference to `__sync_val_compare_and_swap_8' collect2: ld returned 1 exit status g++-4.4.5 (GCC) 4.4.5 Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. i686-pc-linux-gnu /tmp/ccmEomIy.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testIcEvv[void test()]+0x56): undefined reference to `__sync_val_compare_and_swap_1' /tmp/ccmEomIy.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testIhEvv[void test()]+0x47): undefined reference to `__sync_val_compare_and_swap_1' /tmp/ccmEomIy.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testIiEvv[void test()]+0x4b): undefined reference to `__sync_val_compare_and_swap_4' /tmp/ccmEomIy.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testIjEvv[void test()]+0x4b): undefined reference to `__sync_val_compare_and_swap_4' /tmp/ccmEomIy.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testIsEvv[void test()]+0x5f): undefined reference to `__sync_val_compare_and_swap_2' /tmp/ccmEomIy.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testItEvv[void test()]+0x50): undefined reference to `__sync_val_compare_and_swap_2' /tmp/ccmEomIy.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testIlEvv[void test()]+0x4b): undefined reference to `__sync_val_compare_and_swap_4' /tmp/ccmEomIy.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testImEvv[void test()]+0x4b): undefined reference to `__sync_val_compare_and_swap_4' /tmp/ccmEomIy.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x46): undefined reference to `__sync_fetch_and_add_8' gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x5f): undefined reference to `__sync_fetch_and_or_8' gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x78): undefined reference to `__sync_fetch_and_xor_8' gcc-atomic.cpp:(.text._Z4testIxEvv[void test()]+0x9f): undefined reference to `__sync_val_compare_and_swap_8' /tmp/ccmEomIy.o: In function `void test()': gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x45): undefined reference to `__sync_fetch_and_add_8' gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x5e): undefined reference to `__sync_fetch_and_or_8' gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x77): undefined reference to `__sync_fetch_and_xor_8' gcc-atomic.cpp:(.text._Z4testIyEvv[void test()]+0x9e): undefined reference to `__sync_val_compare_and_swap_8' collect2: ld returned 1 exit status g++-4.5.1 (GCC) 4.5.1 Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. i686-pc-linux-gnu