Gleb Natapov wrote:
> On Tue, Mar 06, 2007 at 11:24:06AM +0100, Bert Wesarg wrote:
>> Hello,
>>
>> Gleb Natapov wrote:
>>> If it does this after opal_atomic_lock() (which is explicit memory
>>> barrier) then it is broken.
>> Than, gcc 4.1.1 on the amd64 architecture is broken:
> And can you repeat the test please, but make "test" variable to be global
> to tell compiler that it can be actually accessed by more then one
> thread.
> 

ahh, now both produce nearly the same code.

but who hurts it to declare the variable volatile?

Bert
--- double_check.s	2007-03-06 12:07:12.103478512 +0100
+++ double_check_volatile.s	2007-03-06 12:06:20.675315485 +0100
@@ -1,4 +1,4 @@
-	.file	"double_check.c"
+	.file	"double_check_volatile.c"
 	.text
 	.p2align 4,,15
 .globl main
@@ -13,8 +13,9 @@
 	# first if

 #NO_APP
-	decl	%eax
+	movl	test(%rip), %eax
 	movl	$1, %edx
+	decl	%eax
 	je	.L4
 #APP
 	# lock
@@ -43,7 +44,8 @@
 	# second if

 #NO_APP
-	cmpl	$1, test(%rip)
+	movl	test(%rip), %eax
+	decl	%eax
 	jne	.L8
 #APP
 	# if unlock

Reply via email to