This is the mail archive of the
mailing list for the GCC project.
Re: -fno-tree-cselim not working?
- From: Ian Lance Taylor <iant at google dot com>
- To: Samuel Tardieu <sam at rfc1149 dot net>
- Cc: gcc at gcc dot gnu dot org
- Date: 25 Oct 2007 21:31:56 -0700
- Subject: Re: -fno-tree-cselim not working?
- References: <firstname.lastname@example.org>
Samuel Tardieu <email@example.com> writes:
> #include <pthread.h>
> static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
> static int acquires_count = 0;
> int res;
> res = pthread_mutex_trylock(&mutex);
> if (res == 0)
> return res;
> subl $12, %esp
> movl $mutex, (%esp)
> call pthread_mutex_trylock
> movl acquires_count, %edx
> cmpl $1, %eax
> adcl $0, %edx
> movl %edx, acquires_count
> addl $12, %esp
By the way, since this is getting play on LKML and no doubt other
This optimization (or pessimization, depending) is not new. gcc 4.1
does the same thing. The code has been in there since at least gcc
3.4, though I didn't build gcc 3.4 to test what happened.
Code like needs to use volatile or explicit memory barriers.