From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6260 invoked by alias); 30 Dec 2009 12:57:09 -0000 Received: (qmail 6210 invoked by uid 48); 30 Dec 2009 12:56:51 -0000 Date: Wed, 30 Dec 2009 12:57:00 -0000 Subject: [Bug target/42553] New: wrong code with -O1 X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "debian-gcc at lists dot debian dot org" 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: 2009-12/txt/msg02790.txt.bz2 current trunk/branches on x86_64-linux-gnu. return values with different compilers and different optimizations: -O0 -O1 -O2 -O3 gcc-4.1 0 2 2 2 gcc-4.3 0 2 2 2 gcc-4.4 2 0 0 0 gcc-4.5 0 1 0 0 Matthias #include #include static bool atomic_test_and_reset_bit(unsigned long *v,unsigned long bit) { bool res; __asm__ __volatile__( "btr %2,%1\n" "adc $0,%0\n" :"=r"(res), "=m"(*v) :"r"(bit), "r"(0)) ; return res ? 1 : 0; } int main(void) { unsigned long flags = 0; int j; j = atomic_test_and_reset_bit(&flags, 2); printf("%d\n", j); return 0; } -- Summary: wrong code with -O1 Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: debian-gcc at lists dot debian dot org GCC target triplet: x86_64-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42553